Skip to content

Commit

Permalink
fix loaded_last_id not properly set initially
Browse files Browse the repository at this point in the history
  • Loading branch information
lilydjwg committed Feb 8, 2023
1 parent aee39a1 commit 821feb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion luoxu/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ async def loaded_upto(
direction: Literal[1, -1], msgid: int,
) -> None:
if direction == 1:
sql = '''update tg_groups set loaded_last_id = $1 where group_id = $2 and loaded_last_id < $1'''
sql = '''
update tg_groups set loaded_last_id = $1
where group_id = $2 and
(loaded_last_id < $1 or loaded_last_id is null)
'''
elif direction == -1:
sql = '''update tg_groups set loaded_first_id = $1 where group_id = $2'''
else:
Expand Down

0 comments on commit 821feb3

Please sign in to comment.