fixed time range loading
This commit is contained in:
+20
-19
@@ -64,47 +64,48 @@ class ChannelLogs:
|
|||||||
return
|
return
|
||||||
# load backward
|
# load backward
|
||||||
if is_empty or (
|
if is_empty or (
|
||||||
start_date is not None
|
self.first_message_id is not None
|
||||||
and self.start_date > start_date
|
and (
|
||||||
and self.first_message_id is not None
|
start_date is None
|
||||||
|
or (self.start_date is not None and self.start_date > start_date)
|
||||||
|
)
|
||||||
):
|
):
|
||||||
first_message_id = self.first_message_id
|
|
||||||
first_message_date = None
|
first_message_date = None
|
||||||
tmp_message_id = 0
|
tmp_message_id = 0
|
||||||
done = 0
|
done = 0
|
||||||
while (
|
while (
|
||||||
done >= CHUNK_SIZE
|
first_message_date is None
|
||||||
or first_message_id is None
|
or (
|
||||||
or (first_message_date is None or first_message_date >= start_date)
|
done >= CHUNK_SIZE
|
||||||
and start_date is not None
|
and (start_date is None or first_message_date > start_date)
|
||||||
) and tmp_message_id != first_message_id:
|
)
|
||||||
tmp_message_id = first_message_id
|
) and tmp_message_id != self.first_message_id:
|
||||||
|
tmp_message_id = self.first_message_id
|
||||||
done = 0
|
done = 0
|
||||||
async for message in channel.history(
|
async for message in channel.history(
|
||||||
limit=CHUNK_SIZE,
|
limit=CHUNK_SIZE,
|
||||||
before=FakeMessage(first_message_id)
|
before=FakeMessage(self.first_message_id)
|
||||||
if first_message_id is not None
|
if self.first_message_id is not None
|
||||||
else None,
|
else None,
|
||||||
oldest_first=False,
|
oldest_first=False,
|
||||||
):
|
):
|
||||||
done += 1
|
done += 1
|
||||||
first_message_id = message.id
|
self.first_message_id = message.id
|
||||||
first_message_date = message.created_at
|
first_message_date = message.created_at
|
||||||
m = MessageLog(message, self)
|
m = MessageLog(message, self)
|
||||||
await m.load(message)
|
await m.load(message)
|
||||||
self.messages += [m]
|
self.messages += [m]
|
||||||
yield len(self.messages), False
|
yield len(self.messages), False
|
||||||
if done >= CHUNK_SIZE and first_message_date < start_date:
|
if done < CHUNK_SIZE: # reached bottom
|
||||||
# date was limiting here, store first message id
|
self.first_message_id = None
|
||||||
self.first_message_id = first_message_id
|
|
||||||
self.last_message_id = channel.last_message_id
|
self.last_message_id = channel.last_message_id
|
||||||
# load forward
|
# load forward
|
||||||
if not is_empty:
|
last_message_date = self.messages[0].created_at
|
||||||
|
if not is_empty and (stop_date is None or last_message_date < stop_date):
|
||||||
tmp_message_id = None
|
tmp_message_id = None
|
||||||
last_message_date = self.messages[0].created_at
|
|
||||||
while (
|
while (
|
||||||
self.last_message_id != channel.last_message_id
|
self.last_message_id != channel.last_message_id
|
||||||
or (stop_date is not None and last_message_date <= stop_date)
|
and (stop_date is None or last_message_date < stop_date)
|
||||||
) and self.last_message_id != tmp_message_id:
|
) and self.last_message_id != tmp_message_id:
|
||||||
tmp_message_id = self.last_message_id
|
tmp_message_id = self.last_message_id
|
||||||
async for message in channel.history(
|
async for message in channel.history(
|
||||||
|
|||||||
@@ -195,8 +195,10 @@ class GuildLogs:
|
|||||||
channel
|
channel
|
||||||
for channel in target_channels
|
for channel in target_channels
|
||||||
if channel.id not in self.channels
|
if channel.id not in self.channels
|
||||||
|
or self.channels[channel.id].first_message_id is not None
|
||||||
]
|
]
|
||||||
if len(invalid_target_channels) == 0:
|
if len(invalid_target_channels) == 0:
|
||||||
|
logging.info(f"log {self.guild.id} > assumed fast")
|
||||||
fast = True
|
fast = True
|
||||||
if self.locked:
|
if self.locked:
|
||||||
self.unlock()
|
self.unlock()
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class Scanner(ABC):
|
|||||||
elif total_msg == NO_FILE:
|
elif total_msg == NO_FILE:
|
||||||
await message.channel.send(gdpr.TEXT)
|
await message.channel.send(gdpr.TEXT)
|
||||||
else:
|
else:
|
||||||
if self.start_date is not None:
|
if self.start_date is not None and len(logs.channels) > 0:
|
||||||
self.start_date = max(
|
self.start_date = max(
|
||||||
self.start_date,
|
self.start_date,
|
||||||
min(
|
min(
|
||||||
|
|||||||
Reference in New Issue
Block a user