Skip to content

Search: little optimization when saving search queries #8132

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

Merged
merged 3 commits into from
Jun 1, 2021

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Apr 22, 2021

  • Check max 30 queries, in case there is a flood of queries.
  • Fetch project and version in one query.

I think we can also remove the project relationship,
and only have version, but maybe for later.

- Check max 30 queries, in case there is a flood of queries.
- Fetch project and version in one query.

I think we can also remove the project relationship,
and only have version, but maybe for later.
@stsewd stsewd requested a review from a team April 22, 2021 18:56
@@ -169,33 +169,30 @@ def record_search_query(project_slug, version_slug, query, total_results, time_s

# If a partial query exists,
# then just update that object.
for partial_query in partial_query_qs.iterator():
max_queries = 30
Copy link
Member

Choose a reason for hiding this comment

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

How did you come to this number? What does it mean as a user in the search context? Will it show only 30 results as maximum?

Copy link
Member Author

Choose a reason for hiding this comment

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

It means that we will only search the latest 30 searches that have happened in the last 10 seconds in that project/version. Just a small protection in case we get flooded.

Check max 30 queries, in case there is a flood of queries.

Copy link
Member Author

Choose a reason for hiding this comment

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

and this doesn't have anything to do with the search results a user gets, this code is to save in our db analytics about searches that a project has

@stsewd stsewd enabled auto-merge (squash) June 1, 2021 17:56
@stsewd stsewd merged commit 177dcb1 into master Jun 1, 2021
@stsewd stsewd deleted the opt-save-search branch June 1, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants