From f7cc2a0a58fbaeb4f65912e3602145159461143c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 9 Aug 2011 10:37:37 +0200 Subject: [PATCH 1/2] do not send empty reviews list --- pandora/item/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora/item/models.py b/pandora/item/models.py index 9b213eb7a..093290570 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -437,6 +437,8 @@ class Item(models.Model): if 'reviews' in i: i['reviews'] = self.reviews() + if not i['reviews']: + del i['reviews'] if 'cast' in i and isinstance(i['cast'][0], basestring): i['cast'] = [i['cast']] if 'cast' in i and isinstance(i['cast'][0], list): From 3658b9c170796762a6dc5164c3608702c4f85575 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 9 Aug 2011 12:03:06 +0200 Subject: [PATCH 2/2] special case name facet --- pandora/item/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandora/item/models.py b/pandora/item/models.py index 093290570..eefa443f4 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -499,6 +499,12 @@ class Item(models.Model): if isinstance(values[0], list): values = map(lambda x: {'actor': x[0], 'character': x[1]}, values) values = [i['character'] for i in values] + elif key == 'name': + values = [] + for k in map(lambda x: x['id'], + filter(lambda x: x.get('sort') == 'person', + config['itemKeys'])): + values += self.get(k, []) else: values = self.get(key, '') if isinstance(values, list): @@ -506,6 +512,7 @@ class Item(models.Model): else: save(key, values) + save('summary', self.get('summary', '')) save('trivia', ' '.join(self.get('trivia', []))) @@ -654,6 +661,13 @@ class Item(models.Model): #FIXME: what to do with Unkown Director, Year, Country etc. for key in self.facet_keys: current_values = self.get(key, []) + #FIXME: is there a better way to build name collection? + if key == 'name': + current_values = [] + for k in map(lambda x: x['id'], + filter(lambda x: x.get('sort') == 'person', + config['itemKeys'])): + current_values += self.get(k, []) if not isinstance(current_values, list): current_values = [unicode(current_values)] current_values = list(set(current_values))