Fix
This commit is contained in:
parent
6f8a887ec7
commit
54830ba575
|
@ -184,16 +184,20 @@ class MessageIter:
|
|||
"""Return a iterator for query pagination."""
|
||||
while not self.done:
|
||||
msg_items = MatrixMessage.select().where(
|
||||
MatrixMessage.room_id == self.room.room_id
|
||||
(MatrixMessage.room_id == self.room.room_id)
|
||||
& (MatrixMessage.origin_server_ts < self.last_ts)
|
||||
)
|
||||
if self.sender is not None:
|
||||
msg_items = msg_items.where(MatrixMessage.sender == self.sender)
|
||||
if self.end_date is not None:
|
||||
msg_items = msg_items.where(MatrixMessage.datetime <= self.end_date)
|
||||
msg_items = msg_items.where(MatrixMessage.datetime >= self.end_date)
|
||||
msg_items = msg_items.order_by(MatrixMessage.origin_server_ts.desc()).limit(
|
||||
limit
|
||||
)
|
||||
if msg_items.count() < limit:
|
||||
count = msg_items.count()
|
||||
if count == 0:
|
||||
return
|
||||
elif count < limit:
|
||||
self.done = True
|
||||
yield msg_items
|
||||
|
||||
|
|
Loading…
Reference in New Issue