Skip to content

Commit

Permalink
update crossposting scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ohld committed Jun 9, 2024
1 parent 54bd1af commit c972396
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/crossposting/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ async def log_meme_sent(meme_id: int, channel: Channel) -> None:
async def get_next_meme_for_tgchannelru():
query = """
SELECT
M.id, M.type, M.telegram_file_id, M.caption
M.id
, M.type, M.telegram_file_id, M.caption
----------- DEBUG
-- , MS.nlikes
-- , MS.ndislikes
-- , MS.nmemes_sent
-- , MS.raw_impr_rank
-- , MS.age_days
-- , M.meme_source_id
FROM meme M
LEFT JOIN meme_stats MS
INNER JOIN meme_stats MS
ON MS.meme_id = M.id
LEFT JOIN crossposting CP
ON CP.meme_id = M.id
Expand All @@ -30,11 +39,12 @@ async def get_next_meme_for_tgchannelru():
AND CP.meme_id IS NULL
AND M.status = 'ok'
AND M.language_code = 'ru'
AND MS.nlikes >= 5
ORDER BY -1
* COALESCE((MS.nlikes + 1.) / (MS.nlikes + MS.ndislikes + 1), 0.5)
* CASE WHEN MS.raw_impr_rank < 1 THEN 1 ELSE 0.5 END
* CASE WHEN MS.age_days < 5 THEN 1 ELSE 0.5 END
* CASE WHEN MS.raw_impr_rank <= 1 THEN 1 ELSE 0.8 END
* CASE WHEN MS.age_days < 7 THEN 1 ELSE 0.8 END
* CASE WHEN M.caption IS NULL THEN 1 ELSE 0.8 END
* CASE
WHEN MS.nmemes_sent <= 1 THEN 1
Expand All @@ -58,6 +68,9 @@ async def get_next_meme_for_tgchannelen() -> dict[str, Any]:
-- , MS.nmemes_sent
-- , MSS.nlikes AS source_likes
-- , MSS.ndislikes AS source_dislikes
-- , MS.raw_impr_rank
-- , MS.age_days
-- , M.meme_source_id
FROM meme M
LEFT JOIN meme_stats MS
Expand All @@ -72,14 +85,14 @@ async def get_next_meme_for_tgchannelen() -> dict[str, Any]:
AND CP.meme_id IS NULL
AND M.status = 'ok'
AND M.language_code = 'en'
AND M.meme_source_id not in (173)
AND MS.nlikes >= 5
ORDER BY -1
* COALESCE((MS.nlikes + 1.) / (MS.nlikes + MS.ndislikes + 1), 0.5)
* CASE WHEN MS.raw_impr_rank < 1 THEN 1 ELSE 0.5 END
* CASE WHEN MS.age_days < 5 THEN 1 ELSE 0.5 END
* CASE WHEN M.caption IS NULL THEN 1 ELSE 0.8 END
* CASE WHEN MS.raw_impr_rank <= 1 THEN 1 ELSE 0.5 END
* CASE WHEN MS.age_days < 90 THEN 1 ELSE 0.7 END
* CASE WHEN M.caption IS NULL THEN 1 ELSE 0.9 END
* CASE
WHEN MS.nmemes_sent <= 1 THEN 1
ELSE (MS.nlikes + MS.ndislikes) * 1. / MS.nmemes_sent
Expand Down

0 comments on commit c972396

Please sign in to comment.