forked from 0x2620/pandora
merge
This commit is contained in:
commit
d78385fd9c
3 changed files with 10 additions and 9 deletions
|
@ -28,9 +28,10 @@ class Command(BaseCommand):
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
offset = 0
|
offset = 0
|
||||||
chunk = options['all'] and 100 or options['items']
|
chunk = options['all'] and 100 or options['items']
|
||||||
count = pos = models.Item.objects.count()
|
qs = models.Item.objects.exclude(itemId__startswith='0x')
|
||||||
|
count = pos = qs.count()
|
||||||
while options['all'] and offset <= count or offset < options['items']:
|
while options['all'] and offset <= count or offset < options['items']:
|
||||||
for i in models.Item.objects.all().order_by('modified')[offset:offset+chunk]:
|
for i in qs.order_by('modified')[offset:offset+chunk]:
|
||||||
print pos, i.itemId, i.modified
|
print pos, i.itemId, i.modified
|
||||||
i.update_external()
|
i.update_external()
|
||||||
pos -= 1
|
pos -= 1
|
||||||
|
|
|
@ -7,10 +7,10 @@ from django.db.models import Q
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
k = condition.get('key', 'name')
|
k = condition.get('key', 'name')
|
||||||
k = {
|
k = {
|
||||||
'email': 'user__email',
|
'firstseen': 'created',
|
||||||
'firstseen': 'user__created',
|
'lastseen': 'last_login',
|
||||||
'lastseen': 'user__last_login',
|
'user': 'username',
|
||||||
'user': 'user__username',
|
'name': 'username',
|
||||||
}.get(k, k)
|
}.get(k, k)
|
||||||
v = condition['value']
|
v = condition['value']
|
||||||
op = condition.get('operator')
|
op = condition.get('operator')
|
||||||
|
@ -30,9 +30,9 @@ def parseCondition(condition, user):
|
||||||
|
|
||||||
key = str(key)
|
key = str(key)
|
||||||
if exclude:
|
if exclude:
|
||||||
q = ~Q(**{k: v})
|
q = ~Q(**{key: v})
|
||||||
else:
|
else:
|
||||||
q = Q(**{k: v})
|
q = Q(**{key: v})
|
||||||
return q
|
return q
|
||||||
|
|
||||||
def parseConditions(conditions, operator, user):
|
def parseConditions(conditions, operator, user):
|
||||||
|
|
|
@ -417,6 +417,7 @@ def order_query(qs, sort):
|
||||||
'firstseen': 'date_joined',
|
'firstseen': 'date_joined',
|
||||||
'lastseen': 'last_login',
|
'lastseen': 'last_login',
|
||||||
'username': 'username',
|
'username': 'username',
|
||||||
|
'name': 'username',
|
||||||
}.get(e['key'], 'profile__%s'%e['key'])
|
}.get(e['key'], 'profile__%s'%e['key'])
|
||||||
if key == 'profile__numberoflists':
|
if key == 'profile__numberoflists':
|
||||||
qs = qs.annotate(numberoflists=Sum('lists'))
|
qs = qs.annotate(numberoflists=Sum('lists'))
|
||||||
|
@ -424,7 +425,6 @@ def order_query(qs, sort):
|
||||||
order = '%s%s' % (operator, key)
|
order = '%s%s' % (operator, key)
|
||||||
order_by.append(order)
|
order_by.append(order)
|
||||||
if order_by:
|
if order_by:
|
||||||
print order_by
|
|
||||||
#user table does not support this
|
#user table does not support this
|
||||||
#qs = qs.order_by(*order_by, nulls_last=True)
|
#qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
qs = qs.order_by(*order_by)
|
qs = qs.order_by(*order_by)
|
||||||
|
|
Loading…
Reference in a new issue