Add GIN index to Post.hashtags
This commit is contained in:
parent
fb8f2d1098
commit
1ad9bfcb06
@ -1,5 +1,6 @@
|
|||||||
# Generated by Django 4.1.3 on 2022-11-27 20:16
|
# Generated by Django 4.1.3 on 2022-11-27 20:16
|
||||||
|
|
||||||
|
import django.contrib.postgres.indexes
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
import activities.models.hashtag
|
import activities.models.hashtag
|
||||||
@ -48,4 +49,10 @@ class Migration(migrations.Migration):
|
|||||||
"abstract": False,
|
"abstract": False,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="post",
|
||||||
|
index=django.contrib.postgres.indexes.GinIndex(
|
||||||
|
fields=["hashtags"], name="hashtags_gin"
|
||||||
|
),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@ from typing import Dict, Iterable, Optional, Set
|
|||||||
import httpx
|
import httpx
|
||||||
import urlman
|
import urlman
|
||||||
from asgiref.sync import sync_to_async
|
from asgiref.sync import sync_to_async
|
||||||
|
from django.contrib.postgres.indexes import GinIndex
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.template.defaultfilters import linebreaks_filter
|
from django.template.defaultfilters import linebreaks_filter
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -187,6 +188,11 @@ class Post(StatorModel):
|
|||||||
|
|
||||||
objects = PostManager()
|
objects = PostManager()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
indexes = [
|
||||||
|
GinIndex(fields=["hashtags"], name="hashtags_gin"),
|
||||||
|
]
|
||||||
|
|
||||||
class urls(urlman.Urls):
|
class urls(urlman.Urls):
|
||||||
view = "{self.author.urls.view}posts/{self.id}/"
|
view = "{self.author.urls.view}posts/{self.id}/"
|
||||||
object_uri = "{self.author.actor_uri}posts/{self.id}/"
|
object_uri = "{self.author.actor_uri}posts/{self.id}/"
|
||||||
|
Reference in New Issue
Block a user