forked from 0x2620/pandora
use postgres json field
This commit is contained in:
parent
bbaaeb7263
commit
1bac062a50
24 changed files with 284 additions and 45 deletions
|
|
@ -4,7 +4,6 @@ from django.db.models import Q, Manager
|
|||
|
||||
from oxdjango.managers import get_operator
|
||||
from oxdjango.query import QuerySet
|
||||
from oxdjango.fields import DictField
|
||||
|
||||
|
||||
keymap = {
|
||||
|
|
@ -36,8 +35,7 @@ def parseCondition(condition, user):
|
|||
if isinstance(v, bool):
|
||||
key = k
|
||||
elif k == 'url':
|
||||
key = 'info' + get_operator('=', 'istr')
|
||||
v = DictField.dumps({'url': v})[1:-1]
|
||||
key = 'info__url' + get_operator('=', 'istr')
|
||||
elif k == 'list':
|
||||
q = Q(id=0)
|
||||
l = v.split(":")
|
||||
|
|
|
|||
22
pandora/archive/migrations/0004_jsonfield.py
Normal file
22
pandora/archive/migrations/0004_jsonfield.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-06-19 17:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('archive', '0003_auto_20161104_1726'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "archive_file" ALTER COLUMN "info" TYPE jsonb USING "info"::text::jsonb'
|
||||
),
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "archive_stream" ALTER COLUMN "info" TYPE jsonb USING "info"::text::jsonb'
|
||||
),
|
||||
]
|
||||
|
|
@ -13,6 +13,7 @@ from django.contrib.auth.models import User
|
|||
from django.db import models
|
||||
from django.db.models.signals import pre_delete
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from oxdjango.fields import JSONField
|
||||
|
||||
from oxdjango import fields
|
||||
import ox
|
||||
|
|
@ -69,7 +70,7 @@ class File(models.Model):
|
|||
size = models.BigIntegerField(default=0)
|
||||
duration = models.FloatField(null=True)
|
||||
|
||||
info = fields.DictField(default={})
|
||||
info = JSONField(default=dict, editable=False)
|
||||
|
||||
video_codec = models.CharField(max_length=255)
|
||||
pixel_format = models.CharField(max_length=255)
|
||||
|
|
@ -687,7 +688,7 @@ class Stream(models.Model):
|
|||
source = models.ForeignKey('Stream', related_name='derivatives', default=None, null=True)
|
||||
available = models.BooleanField(default=False)
|
||||
oshash = models.CharField(max_length=16, null=True, db_index=True)
|
||||
info = fields.DictField(default={})
|
||||
info = JSONField(default=dict, editable=False)
|
||||
duration = models.FloatField(default=0)
|
||||
aspect_ratio = models.FloatField(default=0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue