Skip to content

Commit

Permalink
Merge pull request #6142 from readthedocs/fix-search-saving
Browse files Browse the repository at this point in the history
Serialize time in search queries properly
  • Loading branch information
ericholscher authored Sep 6, 2019
2 parents 557c875 + b766388 commit 98a7ff1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion readthedocs/search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def list(self, request, *args, **kwargs):
version_slug,
query,
total_results,
time,
time.isoformat(),
)

return response
6 changes: 4 additions & 2 deletions readthedocs/search/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from dateutil.parser import parse
from django.apps import apps
from django.utils import timezone
from django_elasticsearch_dsl.registries import registry
Expand Down Expand Up @@ -142,17 +143,18 @@ def delete_old_search_queries_from_db():


@app.task(queue='web')
def record_search_query(project_slug, version_slug, query, total_results, time):
def record_search_query(project_slug, version_slug, query, total_results, time_string):
"""Record/update search query in database."""
if not project_slug or not version_slug or not query:
log.debug(
'Not recording the search query. Passed arguments: '
'project_slug: %s, version_slug: %s, query: %s, total_results: %s, time: %s' % (
project_slug, version_slug, query, total_results, time
project_slug, version_slug, query, total_results, time_string
)
)
return

time = parse(time_string)
before_10_sec = time - timezone.timedelta(seconds=10)
partial_query_qs = SearchQuery.objects.filter(
project__slug=project_slug,
Expand Down

0 comments on commit 98a7ff1

Please sign in to comment.