diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/search.py | 18 | ||||
-rw-r--r-- | service/pixelated/adapter/tag_service.py | 1 | ||||
-rw-r--r-- | service/pixelated/user_agent.py | 2 |
3 files changed, 11 insertions, 10 deletions
diff --git a/service/pixelated/adapter/search.py b/service/pixelated/adapter/search.py index df45b76e..69456932 100644 --- a/service/pixelated/adapter/search.py +++ b/service/pixelated/adapter/search.py @@ -16,13 +16,13 @@ class SearchEngine(object): os.makedirs(self.INDEX_FOLDER) self._index = self._create_index() - def _add_to_tags(self, tags, seen, skip_default_tags): + def _add_to_tags(self, tags, seen, skip_default_tags, count_type): for tag, count in seen.iteritems(): if skip_default_tags and tag in self.DEFAULT_TAGS: continue if not tags.get(tag): tags[tag] = {'ident': tag, 'name': tag, 'default': False, 'counts': {'total': 0, 'read': 0}, 'mails': []} - tags[tag]['counts']['read'] += count + tags[tag]['counts'][count_type] += count def _search_tag_groups(self, query): seen = None @@ -44,11 +44,11 @@ class SearchEngine(object): 'ident': default_tag, 'name': default_tag, 'default': True, - 'counts': { - 'total': 0, - 'read': 0 - }, - 'mails': [] + 'counts': { + 'total': 0, + 'read': 0 + }, + 'mails': [] } return tags @@ -56,9 +56,9 @@ class SearchEngine(object): tags = {} if not skip_default_tags: tags = self._init_tags_defaults() - self._add_to_tags(tags, total, skip_default_tags) + self._add_to_tags(tags, total, skip_default_tags, count_type='total') if seen: - self._add_to_tags(tags, seen, skip_default_tags) + self._add_to_tags(tags, seen, skip_default_tags, count_type='read') return tags.values() def tags(self, query, skip_default_tags): diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py index 0a8a1b68..fa70231e 100644 --- a/service/pixelated/adapter/tag_service.py +++ b/service/pixelated/adapter/tag_service.py @@ -31,4 +31,3 @@ class TagService: if not cls.instance: cls.instance = TagService() return cls.instance - diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py index b1233fa3..d6920dc6 100644 --- a/service/pixelated/user_agent.py +++ b/service/pixelated/user_agent.py @@ -158,12 +158,14 @@ def mail_tags(mail_id): @app.route('/mail/<mail_id>/read', methods=['POST']) def mark_mail_as_read(mail_id): mail_service.mark_as_read(mail_id) + search_engine.index_mail(mail) return "" @app.route('/mail/<mail_id>/unread', methods=['POST']) def mark_mail_as_unread(mail_id): mail_service.mark_as_unread(mail_id) + search_engine.index_mail(mail) return "" |