Skip to content

Re-implement looking up multiple messages with more flexibility.#9

Merged
cnweaver merged 1 commit intomasterfrom
new-message-lookup
Feb 13, 2026
Merged

Re-implement looking up multiple messages with more flexibility.#9
cnweaver merged 1 commit intomasterfrom
new-message-lookup

Conversation

@cnweaver
Copy link
Copy Markdown
Collaborator

Allow mixing results across multiple topics, with potentially differing access levels.
Allow reversing the order of results.
Use more efficient paging.

This is the first phase of updates to support a better REST API/Web UI, which includes all changes that could be made without changes to the data stored in the database.

Allow mixing results across multiple topics, with potentially differing access levels.
Allow reversing the order of results.
Use more efficient paging.
@cnweaver cnweaver self-assigned this Dec 19, 2025
@cnweaver cnweaver added the enhancement New feature or request label Dec 19, 2025
Copy link
Copy Markdown

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me. One thing I have noticed is that if you have a topic filter (one or more), then while the initial query is fairly fast (1-2s), each subsequent page load with pagination takes much longer (10-12s). This same slowdown for pagination doesn't seem to appear when no topic filters are present.

Comment thread archive/database_api.py
if offset > 0:
offset -= 1
topics = set()
for record in self.data.values():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like your deleted comment above suggests, this is very inneficient right? Maybe it would be better to cache public topics (and update cached topics on new message ingestion)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh is this just a test fixture - then ignore my comment i guess

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this code path should only be used by tests.

Comment thread archive/database_api.py
else:
full_clause = None
if pub_clause is not None and full_clause is not None:
q = q.where(sqlalchemy.or_(pub_clause, full_clause))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this equally as efficient as combining the topics into one big list and doing a single where topic in clause?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not as efficient, but is required for correctness because the 'public' clause includes different restrictions (topic is one of the public topics, and the message is public). We must not lose that restriction on things with 'public' access level, and don't want to enforce it on things with 'full' access level.

@cnweaver
Copy link
Copy Markdown
Collaborator Author

One thing I have noticed is that if you have a topic filter (one or more), then while the initial query is fairly fast (1-2s), each subsequent page load with pagination takes much longer (10-12s). This same slowdown for pagination doesn't seem to appear when no topic filters are present.

That is not supposed to happen, and I don't think I've seen anything like it in my testing. I'll try to check it again, but do you have any representative API requests for which this occurs?

@cnweaver
Copy link
Copy Markdown
Collaborator Author

After investigation of the perfromance issue, mitigation is possible using an additional meta-data table in the database, which will be added in the next PR.

@cnweaver cnweaver merged commit 94ceb89 into master Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants