summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-28 21:47:31 -0700
committerAndrew Godwin2022-11-28 21:47:31 -0700
commit1ad9bfcb06aec3678c345fd97103f2c73396cd44 (patch)
tree68677716d58fb403a287d43392e4aaa4501d6e69 /activities
parentfb8f2d10984bcfa2585dc272b4c85d285b722792 (diff)
downloadtakahe-1ad9bfcb06aec3678c345fd97103f2c73396cd44.tar.gz
takahe-1ad9bfcb06aec3678c345fd97103f2c73396cd44.tar.bz2
takahe-1ad9bfcb06aec3678c345fd97103f2c73396cd44.zip
Add GIN index to Post.hashtags
Diffstat (limited to 'activities')
-rw-r--r--activities/migrations/0002_hashtag.py7
-rw-r--r--activities/models/post.py6
2 files changed, 13 insertions, 0 deletions
diff --git a/activities/migrations/0002_hashtag.py b/activities/migrations/0002_hashtag.py
index 468bd95..c1b4bbd 100644
--- a/activities/migrations/0002_hashtag.py
+++ b/activities/migrations/0002_hashtag.py
@@ -1,5 +1,6 @@
# Generated by Django 4.1.3 on 2022-11-27 20:16
+import django.contrib.postgres.indexes
from django.db import migrations, models
import activities.models.hashtag
@@ -48,4 +49,10 @@ class Migration(migrations.Migration):
"abstract": False,
},
),
+ migrations.AddIndex(
+ model_name="post",
+ index=django.contrib.postgres.indexes.GinIndex(
+ fields=["hashtags"], name="hashtags_gin"
+ ),
+ ),
]
diff --git a/activities/models/post.py b/activities/models/post.py
index b61abd4..f3b1879 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -4,6 +4,7 @@ from typing import Dict, Iterable, Optional, Set
import httpx
import urlman
from asgiref.sync import sync_to_async
+from django.contrib.postgres.indexes import GinIndex
from django.db import models, transaction
from django.template.defaultfilters import linebreaks_filter
from django.utils import timezone
@@ -187,6 +188,11 @@ class Post(StatorModel):
objects = PostManager()
+ class Meta:
+ indexes = [
+ GinIndex(fields=["hashtags"], name="hashtags_gin"),
+ ]
+
class urls(urlman.Urls):
view = "{self.author.urls.view}posts/{self.id}/"
object_uri = "{self.author.actor_uri}posts/{self.id}/"