mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 02:29:59 +02:00
Fix #994: use PostgreSQL full-text-search
This commit is contained in:
parent
8f0eabcb71
commit
b3d8d6a4da
6 changed files with 148 additions and 5 deletions
|
@ -11,6 +11,8 @@ import pydub
|
|||
from django.conf import settings
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.contrib.postgres.search import SearchVectorField
|
||||
from django.contrib.postgres.indexes import GinIndex
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
@ -19,7 +21,6 @@ from django.db.models.signals import post_save, pre_save
|
|||
from django.dispatch import receiver
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from versatileimagefield.fields import VersatileImageField
|
||||
|
||||
from funkwhale_api import musicbrainz
|
||||
|
@ -56,10 +57,14 @@ class APIModelMixin(models.Model):
|
|||
api_includes = []
|
||||
creation_date = models.DateTimeField(default=timezone.now, db_index=True)
|
||||
import_hooks = []
|
||||
body_text = SearchVectorField(blank=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
ordering = ["-creation_date"]
|
||||
indexes = [
|
||||
GinIndex(fields=["body_text"]),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def get_or_create_from_api(cls, mbid):
|
||||
|
@ -524,6 +529,9 @@ class Track(APIModelMixin):
|
|||
|
||||
class Meta:
|
||||
ordering = ["album", "disc_number", "position"]
|
||||
indexes = [
|
||||
GinIndex(fields=["body_text"]),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue