Skip to content

Commit

Permalink
Add needs_update() in index_forum_threads.py
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Apr 14, 2024
1 parent 5728e26 commit 6570868
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions yellowstone/job/index_forum_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@ class ForumThreadsJob(TypedDict):
category_id: int


class ForumThreadProgressRow(TypedDict):
post_count: int
last_post_id: Optional[int]


def run(core: "BackupDispatcher", data: ForumThreadsJob) -> None:
# TODO
pass


def needs_update(
last_progress: ForumThreadProgressRow,
thread: forum_threads.ForumThreadData,
) -> bool:
if thread.post_count > last_progress["last_post_id"]:
logger.debug(
"Forum thread %d has more posts (%d > %d)",
thread.id,
thread.post_count,
last_progress["post_count"],
)
return True

if thread.last_post is not None:
last_post_id = last_progress["last_post_id"] or 0
if thread.last_post.post_id > last_post_id:
logger.debug(
"Forum thread %d has a new post ID (%d > %d)",
thread.id,
last_post_id,
)
return True

logger.debug("Forum thread %d has nothing new to index", thread.id)
return False

0 comments on commit 6570868

Please sign in to comment.