-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4479 from freelawproject/4230_search_query_sugges…
…ted_changes 4230 Create SearchQuery model to store user's queries
- Loading branch information
Showing
6 changed files
with
482 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Generated by Django 5.1.1 on 2024-10-14 15:20 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("search", "0035_pghistory_v3_4_0_trigger_update"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="SearchQuery", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"source", | ||
models.SmallIntegerField( | ||
choices=[(1, "Website"), (2, "API request")], | ||
help_text="The interface used to perform the query.", | ||
), | ||
), | ||
( | ||
"get_params", | ||
models.TextField( | ||
help_text="The GET parameters of the search query." | ||
), | ||
), | ||
( | ||
"query_time_ms", | ||
models.IntegerField( | ||
help_text="The milliseconds to execute the query, as returned in the ElasticSearch or Solr response.", | ||
null=True, | ||
), | ||
), | ||
( | ||
"hit_cache", | ||
models.BooleanField( | ||
help_text="Whether the query hit the cache or not." | ||
), | ||
), | ||
( | ||
"failed", | ||
models.BooleanField( | ||
help_text="True if there was an error executing the query." | ||
), | ||
), | ||
( | ||
"engine", | ||
models.SmallIntegerField( | ||
choices=[(1, "Elasticsearch"), (2, "Solr")], | ||
help_text="The engine that executed the search", | ||
), | ||
), | ||
( | ||
"date_created", | ||
models.DateTimeField( | ||
auto_now_add=True, | ||
help_text="Datetime when the record was created.", | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
blank=True, | ||
help_text="The user who performed this search query.", | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="search_queries", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"indexes": [ | ||
models.Index( | ||
fields=["date_created"], | ||
name="search_sear_date_cr_c5fff9_idx", | ||
) | ||
], | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- | ||
-- Create model SearchQuery | ||
-- | ||
CREATE TABLE "search_searchquery" ("id" integer NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "source" smallint NOT NULL, "get_params" text NOT NULL, "query_time_ms" integer NULL, "hit_cache" boolean NOT NULL, "failed" boolean NOT NULL, "engine" smallint NOT NULL, "date_created" timestamp with time zone NOT NULL, "user_id" integer NULL); | ||
ALTER TABLE "search_searchquery" ADD CONSTRAINT "search_searchquery_user_id_8918791c_fk_auth_user_id" FOREIGN KEY ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED; | ||
CREATE INDEX "search_searchquery_user_id_8918791c" ON "search_searchquery" ("user_id"); | ||
CREATE INDEX "search_sear_date_cr_c5fff9_idx" ON "search_searchquery" ("date_created"); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.