Closed jchristgit closed 2 weeks ago
We listen to the former of the two events here https://github.com/python-discord/metricity/blob/main/metricity/exts/event_listeners/guild_listeners.py#L56-L62
Have you seen an example a thread's archive state not being updated? we might need to start listening to the second if so.
I didn't bother listening to the second event originally as my understanding was an active thread should always be in the bot's cache, so archiving a thread should mean that it always triggers the first event.
Thanks for the quick reply!
We listen to the former of the two events here https://github.com/python-discord/metricity/blob/main/metricity/exts/event_listeners/guild_listeners.py#L56-L62
I missed this, thank you for linking to it.
Have you seen an example a thread's archive state not being updated? we might need to start listening to the second if so.
Yes. I've done some data exploration on lovelace in metricity earlier today, and found this:
metricity=# SELECT COUNT(*) FROM threads WHERE NOT archived; -- pre metricity restart
count
-------
1389
(1 row)
metricity=# SELECT COUNT(*) FROM threads WHERE NOT archived; -- post metricity restart
count
-------
88
(1 row)
I'm not sure if it's necessarily the lacking raw event handler, although the sync function seems to be working correctly based on the result after successful startup.
I didn't bother listening to the second event originally as my understanding was an active thread should always be in the bot's cache, so archiving a thread should mean that it always triggers the first event.
Hm, it seems intuitive to me as well, but maybe that is not how it works.
By the way, reading the code as I understand it currently we will synchronize each of the current threads on the guild on any thread update. Maybe we could make it more granular. Although since this is just a few dozen it shouldn't matter too much, this isn't the user cache after all.
Just spotted why, https://github.com/python-discord/metricity/pull/156 should fix this
currently we will synchronize each of the current threads on the guild on any thread update
Yeah just spotted this too, seems quite heavy handed, but as you say it's still a small number of queries as far as postres is concerned
Currently the thread archive state is only synchronized on startup. This means that the
archived
flag on threads in the database slowly runs out of sync.We should probably listen for
on_thread_update
oron_raw_thread_update
here and update the database accordingly.