Sentinel History Rewrite #81

Merged
cswimr merged 12 commits from feat/history-rewrite into main 2026-02-21 01:52:09 -05:00
Owner

This pull request completely rewrites Sentinel's history method, pulling it out of SentinelCog and into its own views.history module. Closes #78.

The new API can be accessed at tidegear.sentinel.HistoryView.

This also includes changes to Tidegear's emoji system, but they're internal and shouldn't qualify as a breaking change (only private attributes / methods were changed in an incompatible way).

The new history system works as such:

  • Consumer calls HistoryView.send() with their filters.
  • That method constructs a _HistoryOpts object, which ties into SentinelCog methods to actually fetch moderations.
  • Two Piccolo queries are made at this point. One to fetch the first <pagesize> moderations that satisfy the given filters, and one to count the number of rows that satisfy the given filters. This COUNT query is not repeated again in normal usage.
  • A couple fields on the _HistoryOpts object are hydrated with the query results. This is then used to compute the total number of pages for the given <pagesize>.
  • An embed is constructed with information on each of the fetched moderations.
  • Buttons are constructed and added to the view, accordingly with the number of available pages. If there are more total moderations than were retrieved accordingly to <pagesize>, pagination buttons will be available.
    • Different pagination buttons have different operational methods. Next/Back use keyset pagination, whereas First/Last/Jump to Page use offset pagination. Next/Back will be much faster as databases grow in row count, but for realistic usage, offset pagination is probably fine, and it'd be prohibitively difficult to implement keyset pagination for those other buttons.
  • Embed and view gets sent to user.

Not including message sending, the new system is about 412x or 99.76% faster than the legacy history method.

Old:

[red.tidegear.TidegearExampleCog.sentinel] History query completed in 38,144.360 ms with 14,483 moderations retrieved! Query construction time: '18.967 ms' Query time: '10,581.014 ms' Moderation iteration time: '27,544.379 ms' Longest moderation iteration: 'Moderation 7,128 with 6.017 ms' Avg. time per moderation: '1.902 ms'

New:

[red.tidegear.TidegearExampleCog.sentinel] History menu creation completed in 0.689468 seconds with 12 moderations retrieved. Query time: '87.049682 milliseconds' Moderation iteration time: '5.440367 milliseconds' Longest moderation interaction: 'Moderation 14483 with 0.851507 milliseconds' Avg. time per moderation: '0.453364 milliseconds' Message send time: '342.008403 milliseconds'
This pull request completely rewrites Sentinel's history method, pulling it out of `SentinelCog` and into its own `views.history` module. Closes #78. The new API can be accessed at `tidegear.sentinel.HistoryView`. This also includes changes to Tidegear's emoji system, but they're internal and shouldn't qualify as a breaking change (only private attributes / methods were changed in an incompatible way). The new history system works as such: - Consumer calls `HistoryView.send()` with their filters. - That method constructs a `_HistoryOpts` object, which ties into `SentinelCog` methods to actually fetch moderations. - Two Piccolo queries are made at this point. One to fetch the first `<pagesize>` moderations that satisfy the given filters, and one to count the number of rows that satisfy the given filters. **This `COUNT` query is not repeated again in normal usage.** - A couple fields on the `_HistoryOpts` object are hydrated with the query results. This is then used to compute the total number of pages for the given `<pagesize>`. - An embed is constructed with information on each of the fetched moderations. - Buttons are constructed and added to the view, accordingly with the number of available pages. If there are more total moderations than were retrieved accordingly to `<pagesize>`, pagination buttons will be available. - Different pagination buttons have different operational methods. `Next`/`Back` use keyset pagination, whereas `First`/`Last`/`Jump to Page` use offset pagination. `Next`/`Back` will be much faster as databases grow in row count, but for realistic usage, offset pagination is probably fine, and it'd be prohibitively difficult to implement keyset pagination for those other buttons. - Embed and view gets sent to user. Not including message sending, the new system is about **412x or 99.76% faster** than the legacy history method. Old: ``` [red.tidegear.TidegearExampleCog.sentinel] History query completed in 38,144.360 ms with 14,483 moderations retrieved! Query construction time: '18.967 ms' Query time: '10,581.014 ms' Moderation iteration time: '27,544.379 ms' Longest moderation iteration: 'Moderation 7,128 with 6.017 ms' Avg. time per moderation: '1.902 ms' ``` New: ``` [red.tidegear.TidegearExampleCog.sentinel] History menu creation completed in 0.689468 seconds with 12 moderations retrieved. Query time: '87.049682 milliseconds' Moderation iteration time: '5.440367 milliseconds' Longest moderation interaction: 'Moderation 14483 with 0.851507 milliseconds' Avg. time per moderation: '0.453364 milliseconds' Message send time: '342.008403 milliseconds' ```
cswimr self-assigned this 2026-02-20 12:00:34 -05:00
initial publish
Some checks failed
Actions / Build (pull_request) Successful in 37s
Actions / Lint (pull_request) Failing after 40s
Actions / Run Tests (pull_request) Successful in 40s
Actions / Build Documentation (pull_request) Successful in 59s
423a001db9
add seconds_to_milliseconds utility function; add proper logging calls for sentinel_history and _sentinel_history_count; improve logging calls in _sentinel_expiry_handler
Some checks failed
Actions / Run Tests (pull_request) Successful in 19s
Actions / Lint (pull_request) Failing after 33s
Actions / Build (pull_request) Successful in 38s
Actions / Build Documentation (pull_request) Successful in 1m1s
5fdacf129f
HistoryView menu fixes
Some checks failed
Actions / Run Tests (pull_request) Successful in 14s
Actions / Lint (pull_request) Failing after 33s
Actions / Build (pull_request) Successful in 38s
Actions / Build Documentation (pull_request) Successful in 58s
cf83973744
tweak labels; remove keyset pagination logic from modal
Some checks failed
Actions / Build (pull_request) Successful in 12s
Actions / Lint (pull_request) Failing after 32s
Actions / Run Tests (pull_request) Successful in 38s
Actions / Build Documentation (pull_request) Successful in 59s
dc370b6203
simply HistoryView timeout behavior; fix _HistoryPageModal bug
Some checks failed
Actions / Build (pull_request) Successful in 13s
Actions / Lint (pull_request) Failing after 33s
Actions / Run Tests (pull_request) Successful in 39s
Actions / Build Documentation (pull_request) Successful in 1m0s
d96c43d255
add documentation; various other tweaks
Some checks failed
Actions / Build (pull_request) Successful in 12s
Actions / Run Tests (pull_request) Successful in 40s
Actions / Lint (pull_request) Successful in 46s
Actions / Build Documentation (pull_request) Failing after 39s
f3f3689697
remove sentinel_history_menu method
Some checks failed
Actions / Run Tests (pull_request) Successful in 14s
Actions / Build (pull_request) Successful in 38s
Actions / Lint (pull_request) Has been cancelled
Actions / Build Documentation (pull_request) Has been cancelled
86935fb053
fix docs typo
Some checks failed
Actions / Run Tests (pull_request) Successful in 14s
Actions / Build (pull_request) Successful in 38s
Actions / Lint (pull_request) Successful in 46s
Actions / Build Documentation (pull_request) Failing after 47s
ba7bc86858
fix documentation
All checks were successful
Actions / Build (pull_request) Successful in 12s
Actions / Run Tests (pull_request) Successful in 40s
Actions / Lint (pull_request) Successful in 46s
Actions / Build Documentation (pull_request) Successful in 59s
16f4ac9e87
cswimr changed title from WIP: Sentinel History Rewrite to Sentinel History Rewrite 2026-02-21 01:50:09 -05:00
cswimr merged commit 89af26cbb9 into main 2026-02-21 01:52:09 -05:00
cswimr deleted branch feat/history-rewrite 2026-02-21 01:52:10 -05:00
cswimr referenced this pull request from a commit 2026-02-21 01:52:11 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cswimr/tidegear!81
No description provided.