forked from 0x2620/pandora
groups, not use map
This commit is contained in:
parent
9fc7fd2f05
commit
2abc2d9368
1 changed files with 7 additions and 10 deletions
|
@ -184,18 +184,15 @@ Positions
|
||||||
name = 'name'
|
name = 'name'
|
||||||
items = 'movies'
|
items = 'movies'
|
||||||
movie_qs = query['qs']
|
movie_qs = query['qs']
|
||||||
_objects = {
|
|
||||||
'country': models.Country.objects,
|
|
||||||
'genre': models.Genre.objects,
|
|
||||||
'language': models.Language.objects,
|
|
||||||
'director': models.Cast.objects.filter(role='directors'),
|
|
||||||
}
|
|
||||||
if query['group'] == "director":
|
if query['group'] == "director":
|
||||||
qs = _objects[query['group']].filter(movie__id__in=movie_qs).values('person__name').annotate(movies=Count('person__id')).order_by()
|
qs = models.Cast.objects.filter(role='directors').filter(movie__id__in=movie_qs).values('person__name').annotate(movies=Count('person__id')).order_by()
|
||||||
name = 'person__name'
|
name = 'person__name'
|
||||||
|
elif query['group'] == "country":
|
||||||
elif query['group'] in _objects:
|
qs = models.Country.objects.filter(movies__id__in=movie_qs).values('name').annotate(movies=Count('id'))
|
||||||
qs = _objects[query['group']].filter(movies__id__in=movie_qs).values('name').annotate(movies=Count('movies'))
|
elif query['group'] == "genre":
|
||||||
|
qs = models.Genre.objects.filter(movies__id__in=movie_qs).values('name').annotate(movies=Count('id'))
|
||||||
|
elif query['group'] == "language":
|
||||||
|
qs = models.Language.objects.filter(movies__id__in=movie_qs).values('name').annotate(movies=Count('id'))
|
||||||
elif query['group'] == "year":
|
elif query['group'] == "year":
|
||||||
qs = models.MovieSort.objects.filter(movie__id__in=movie_qs).values('year').annotate(movies=Count('year'))
|
qs = models.MovieSort.objects.filter(movie__id__in=movie_qs).values('year').annotate(movies=Count('year'))
|
||||||
name='year'
|
name='year'
|
||||||
|
|
Loading…
Reference in a new issue