-
Notifications
You must be signed in to change notification settings - Fork 1k
Partial search updates #3693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial search updates #3693
Conversation
warehouse/search/__init__.py
Outdated
def store_projects_for_project_reindex(config, session, flush_context): | ||
# We'll (ab)use the session.info dictionary to store a list of pending | ||
# Project updates to the session. | ||
purges = session.info.setdefault("warehouse.search.project_updates", set()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to call this something other than purges
... reindexable
? changed_projects
? updated_projects
?
warehouse/search/tasks.py
Outdated
@@ -87,6 +87,9 @@ def _project_docs(db): | |||
.order_by(Release.name) | |||
) | |||
|
|||
if project_name: | |||
release_data = release_data.filter(Release.name == project_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to add this filter earlier on releases_list
instead of here? Maybe it makes no difference...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's damn fast either way, but you're right!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, since releases_list
is a subquery, it seems it is not easily modified after the fact. probably best to let this sleeping dog lay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just .subquery
it later, and do releases_list = releases_list.filter(...)
earlier. Again, might not really matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
easy enough.
warehouse/search/__init__.py
Outdated
# a Project to reindex for when the session has been committed. | ||
for obj in (session.new | session.dirty | session.deleted): | ||
if obj.__class__ == Project: | ||
purges.add(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the project has been deleted, I'm not sure it makes sense to add it to the set here, because the .filter
below will not return any releases at all. (I guess a deleted project can just fall out of the index when we reindex nightly instead of trying to do something special for it here.)
However if a release has been deleted, it does make sense.
warehouse/search/__init__.py
Outdated
|
||
@db.listens_for(db.Session, "after_commit") | ||
def execute_project_reindex(config, session): | ||
purges = session.info.pop("warehouse.search.project_updates", set()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here.
A fools attempt at #701
Incrementally reindexes new documents or unindexes whenever a Project or Release is created, updated, or deleted.