|
1 | 1 | import logging
|
2 | 2 |
|
| 3 | +from dateutil.parser import parse |
3 | 4 | from django.apps import apps
|
4 | 5 | from django.utils import timezone
|
5 | 6 | from django_elasticsearch_dsl.registries import registry
|
@@ -142,17 +143,18 @@ def delete_old_search_queries_from_db():
|
142 | 143 |
|
143 | 144 |
|
144 | 145 | @app.task(queue='web')
|
145 |
| -def record_search_query(project_slug, version_slug, query, total_results, time): |
| 146 | +def record_search_query(project_slug, version_slug, query, total_results, time_string): |
146 | 147 | """Record/update search query in database."""
|
147 | 148 | if not project_slug or not version_slug or not query:
|
148 | 149 | log.debug(
|
149 | 150 | 'Not recording the search query. Passed arguments: '
|
150 | 151 | 'project_slug: %s, version_slug: %s, query: %s, total_results: %s, time: %s' % (
|
151 |
| - project_slug, version_slug, query, total_results, time |
| 152 | + project_slug, version_slug, query, total_results, time_string |
152 | 153 | )
|
153 | 154 | )
|
154 | 155 | return
|
155 | 156 |
|
| 157 | + time = parse(time_string) |
156 | 158 | before_10_sec = time - timezone.timedelta(seconds=10)
|
157 | 159 | partial_query_qs = SearchQuery.objects.filter(
|
158 | 160 | project__slug=project_slug,
|
|
0 commit comments