We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Stats table shows no zero counts
This can be seen in the following screenshot:

![no-zero-counts](https://cloud.githubusercontent.com/assets/939880/21317886/55bed600-c607-11e6-8fb6-44099121b6af.png)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pootle/core/views/display.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) Pootle contributors.
4 #
5 # This file is a part of the Pootle project. It is distributed under the GPL3
6 # or later license. See the LICENSE file for a copy of the license and the
7 # AUTHORS file for copyright and authorship information.
8 
9 from django.utils.functional import cached_property
10 from django.utils.html import escape, format_html
11 from django.utils.safestring import mark_safe
12 
13 from pootle.i18n import formatter
14 from pootle.i18n.gettext import ugettext as _
15 from pootle.local.dates import timesince
16 from pootle_misc.checks import get_qualitycheck_list
17 
18 
19 class ActionDisplay(object):
20 
21     def __init__(self, action):
22         self.action = action
23 
24     @property
25     def since(self):
26         return timesince(self.action["mtime"])
27 
28     @property
29     def check_name(self):
30         return self.action.get("check_name")
31 
32     @property
33     def checks_url(self):
34         return self.action.get("checks_url")
35 
36     @property
37     def check_display_name(self):
38         return escape(self.action["check_display_name"])
39 
40     @property
41     def display_name(self):
42         return escape(self.action["displayname"])
43 
44     @property
45     def profile_url(self):
46         return self.action["profile_url"]
47 
48     @property
49     def unit_url(self):
50         return self.action.get("unit_url")
51 
52     @property
53     def unit_source(self):
54         return self.action.get("unit_source")
55 
56     @property
57     def params(self):
58         params = dict(
59             user=self.formatted_user,
60             source=self.formatted_source)
61         if self.check_name:
62             params["check"] = format_html(
63                 u"<a href='{}'>{}</a>",
64                 self.checks_url,
65                 self.check_display_name)
66         return params
67 
68     @property
69     def formatted_user(self):
70         return format_html(
71             u"<a href='{}' class='user-name'>{}</a>",
72             self.profile_url,
73             self.display_name)
74 
75     @property
76     def formatted_source(self):
77         return format_html(
78             u"<a href='{}'>{}</a>",
79             self.unit_url,
80             self.unit_source)
81 
82     @property
83     def action_type(self):
84         return self.action["type"]
85 
86     @property
87     def translation_action_type(self):
88         return self.action.get("translation_action_type")
89 
90     @property
91     def message(self):
92         msg = ""
93         params = self.params
94         if (self.action_type == 2):
95             msg = _('%(user)s removed translation for %(source)s', params)
96         if (self.action_type == 3):
97             msg = _('%(user)s accepted suggestion for %(source)s', params)
98         if (self.action_type == 4):
99             msg = _('%(user)s uploaded file', params)
100         if (self.action_type == 6):
101             msg = _('%(user)s muted %(check)s for %(source)s', params)
102         if (self.action_type == 7):
103             msg = _('%(user)s unmuted %(check)s for %(source)s', params)
104         if (self.action_type == 8):
105             msg = _('%(user)s added suggestion for %(source)s', params)
106         if (self.action_type == 9):
107             msg = _('%(user)s rejected suggestion for %(source)s', params)
108         if (self.action_type in [1, 5]):
109             if self.translation_action_type == 0:
110                 msg = _('%(user)s translated %(source)s', params)
111             if self.translation_action_type == 1:
112                 msg = _('%(user)s edited %(source)s', params)
113             if self.translation_action_type == 2:
114                 msg = _('%(user)s pre-translated %(source)s', params)
115             if self.translation_action_type == 3:
116                 msg = _('%(user)s removed translation for %(source)s', params)
117             if self.translation_action_type == 4:
118                 msg = _('%(user)s reviewed %(source)s', params)
119             if self.translation_action_type == 5:
120                 msg = _('%(user)s marked as needs work %(source)s', params)
121         return mark_safe(msg)
122 
123 
124 class ChecksDisplay(object):
125 
126     def __init__(self, context):
127         self.context = context
128 
129     @property
130     def check_schema(self):
131         return get_qualitycheck_list(self.context)
132 
133     @cached_property
134     def check_data(self):
135         return self.context.data_tool.get_checks()
136 
137     @property
138     def checks_by_category(self):
139         _checks = []
140         for check in self.check_schema:
141             if check["code"] not in self.check_data:
142                 continue
143             check["count"] = self.check_data[check["code"]]
144             check["count_display"] = formatter.number(check["count"])
145             _checks.append(check)
146         return _checks
147 
148 
149 class StatsDisplay(object):
150 
151     def __init__(self, context, stats=None):
152         self.context = context
153         self._stats = stats
154 
155     @staticmethod
156     def make_display_stat(d, keys=["total", "critical", "incomplete",
157                                    "suggestions", "fuzzy", "untranslated"]):
158         assert isinstance(d, dict)
159         for k in keys:
160             if d.get(k):
161                 d[k + '_display'] = formatter.number(d[k])
162 
163     @cached_property
164     def stat_data(self):
165         if self._stats is not None:
166             return self._stats
167         return self.context.data_tool.get_stats()
168 
169     @cached_property
170     def stats(self):
171         stats = self.stat_data
172         self.add_children_info(stats)
173         self.make_display_stat(stats)
174         if stats.get("last_submission"):
175             stats["last_submission"]["msg"] = (
176                 self.get_action_message(stats["last_submission"]))
177         return stats
178 
179     def add_children_info(self, stats):
180         for k, child in stats["children"].items():
181             child["incomplete"] = child["total"] - child["translated"]
182             child["untranslated"] = child["total"] - child["translated"]
183             self.make_display_stat(child)
184 
185     def get_action_message(self, action):
186         return ActionDisplay(action).message
187
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pootle/core/views/display.py b/pootle/core/views/display.py
--- a/pootle/core/views/display.py
+++ b/pootle/core/views/display.py
@@ -157,7 +157,7 @@
                                    "suggestions", "fuzzy", "untranslated"]):
         assert isinstance(d, dict)
         for k in keys:
-            if d.get(k):
+            if k in d:
                 d[k + '_display'] = formatter.number(d[k])
 
     @cached_property

{"golden_diff": "diff --git a/pootle/core/views/display.py b/pootle/core/views/display.py\n--- a/pootle/core/views/display.py\n+++ b/pootle/core/views/display.py\n@@ -157,7 +157,7 @@\n                                    \"suggestions\", \"fuzzy\", \"untranslated\"]):\n         assert isinstance(d, dict)\n         for k in keys:\n-            if d.get(k):\n+            if k in d:\n                 d[k + '_display'] = formatter.number(d[k])\n \n     @cached_property\n", "issue": "Stats table shows no zero counts\nThis can be seen in the following screenshot:\r\n\r\n![no-zero-counts](https://cloud.githubusercontent.com/assets/939880/21317886/55bed600-c607-11e6-8fb6-44099121b6af.png)\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.utils.functional import cached_property\nfrom django.utils.html import escape, format_html\nfrom django.utils.safestring import mark_safe\n\nfrom pootle.i18n import formatter\nfrom pootle.i18n.gettext import ugettext as _\nfrom pootle.local.dates import timesince\nfrom pootle_misc.checks import get_qualitycheck_list\n\n\nclass ActionDisplay(object):\n\n    def __init__(self, action):\n        self.action = action\n\n    @property\n    def since(self):\n        return timesince(self.action[\"mtime\"])\n\n    @property\n    def check_name(self):\n        return self.action.get(\"check_name\")\n\n    @property\n    def checks_url(self):\n        return self.action.get(\"checks_url\")\n\n    @property\n    def check_display_name(self):\n        return escape(self.action[\"check_display_name\"])\n\n    @property\n    def display_name(self):\n        return escape(self.action[\"displayname\"])\n\n    @property\n    def profile_url(self):\n        return self.action[\"profile_url\"]\n\n    @property\n    def unit_url(self):\n        return self.action.get(\"unit_url\")\n\n    @property\n    def unit_source(self):\n        return self.action.get(\"unit_source\")\n\n    @property\n    def params(self):\n        params = dict(\n            user=self.formatted_user,\n            source=self.formatted_source)\n        if self.check_name:\n            params[\"check\"] = format_html(\n                u\"<a href='{}'>{}</a>\",\n                self.checks_url,\n                self.check_display_name)\n        return params\n\n    @property\n    def formatted_user(self):\n        return format_html(\n            u\"<a href='{}' class='user-name'>{}</a>\",\n            self.profile_url,\n            self.display_name)\n\n    @property\n    def formatted_source(self):\n        return format_html(\n            u\"<a href='{}'>{}</a>\",\n            self.unit_url,\n            self.unit_source)\n\n    @property\n    def action_type(self):\n        return self.action[\"type\"]\n\n    @property\n    def translation_action_type(self):\n        return self.action.get(\"translation_action_type\")\n\n    @property\n    def message(self):\n        msg = \"\"\n        params = self.params\n        if (self.action_type == 2):\n            msg = _('%(user)s removed translation for %(source)s', params)\n        if (self.action_type == 3):\n            msg = _('%(user)s accepted suggestion for %(source)s', params)\n        if (self.action_type == 4):\n            msg = _('%(user)s uploaded file', params)\n        if (self.action_type == 6):\n            msg = _('%(user)s muted %(check)s for %(source)s', params)\n        if (self.action_type == 7):\n            msg = _('%(user)s unmuted %(check)s for %(source)s', params)\n        if (self.action_type == 8):\n            msg = _('%(user)s added suggestion for %(source)s', params)\n        if (self.action_type == 9):\n            msg = _('%(user)s rejected suggestion for %(source)s', params)\n        if (self.action_type in [1, 5]):\n            if self.translation_action_type == 0:\n                msg = _('%(user)s translated %(source)s', params)\n            if self.translation_action_type == 1:\n                msg = _('%(user)s edited %(source)s', params)\n            if self.translation_action_type == 2:\n                msg = _('%(user)s pre-translated %(source)s', params)\n            if self.translation_action_type == 3:\n                msg = _('%(user)s removed translation for %(source)s', params)\n            if self.translation_action_type == 4:\n                msg = _('%(user)s reviewed %(source)s', params)\n            if self.translation_action_type == 5:\n                msg = _('%(user)s marked as needs work %(source)s', params)\n        return mark_safe(msg)\n\n\nclass ChecksDisplay(object):\n\n    def __init__(self, context):\n        self.context = context\n\n    @property\n    def check_schema(self):\n        return get_qualitycheck_list(self.context)\n\n    @cached_property\n    def check_data(self):\n        return self.context.data_tool.get_checks()\n\n    @property\n    def checks_by_category(self):\n        _checks = []\n        for check in self.check_schema:\n            if check[\"code\"] not in self.check_data:\n                continue\n            check[\"count\"] = self.check_data[check[\"code\"]]\n            check[\"count_display\"] = formatter.number(check[\"count\"])\n            _checks.append(check)\n        return _checks\n\n\nclass StatsDisplay(object):\n\n    def __init__(self, context, stats=None):\n        self.context = context\n        self._stats = stats\n\n    @staticmethod\n    def make_display_stat(d, keys=[\"total\", \"critical\", \"incomplete\",\n                                   \"suggestions\", \"fuzzy\", \"untranslated\"]):\n        assert isinstance(d, dict)\n        for k in keys:\n            if d.get(k):\n                d[k + '_display'] = formatter.number(d[k])\n\n    @cached_property\n    def stat_data(self):\n        if self._stats is not None:\n            return self._stats\n        return self.context.data_tool.get_stats()\n\n    @cached_property\n    def stats(self):\n        stats = self.stat_data\n        self.add_children_info(stats)\n        self.make_display_stat(stats)\n        if stats.get(\"last_submission\"):\n            stats[\"last_submission\"][\"msg\"] = (\n                self.get_action_message(stats[\"last_submission\"]))\n        return stats\n\n    def add_children_info(self, stats):\n        for k, child in stats[\"children\"].items():\n            child[\"incomplete\"] = child[\"total\"] - child[\"translated\"]\n            child[\"untranslated\"] = child[\"total\"] - child[\"translated\"]\n            self.make_display_stat(child)\n\n    def get_action_message(self, action):\n        return ActionDisplay(action).message\n", "path": "pootle/core/views/display.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.utils.functional import cached_property\nfrom django.utils.html import escape, format_html\nfrom django.utils.safestring import mark_safe\n\nfrom pootle.i18n import formatter\nfrom pootle.i18n.gettext import ugettext as _\nfrom pootle.local.dates import timesince\nfrom pootle_misc.checks import get_qualitycheck_list\n\n\nclass ActionDisplay(object):\n\n    def __init__(self, action):\n        self.action = action\n\n    @property\n    def since(self):\n        return timesince(self.action[\"mtime\"])\n\n    @property\n    def check_name(self):\n        return self.action.get(\"check_name\")\n\n    @property\n    def checks_url(self):\n        return self.action.get(\"checks_url\")\n\n    @property\n    def check_display_name(self):\n        return escape(self.action[\"check_display_name\"])\n\n    @property\n    def display_name(self):\n        return escape(self.action[\"displayname\"])\n\n    @property\n    def profile_url(self):\n        return self.action[\"profile_url\"]\n\n    @property\n    def unit_url(self):\n        return self.action.get(\"unit_url\")\n\n    @property\n    def unit_source(self):\n        return self.action.get(\"unit_source\")\n\n    @property\n    def params(self):\n        params = dict(\n            user=self.formatted_user,\n            source=self.formatted_source)\n        if self.check_name:\n            params[\"check\"] = format_html(\n                u\"<a href='{}'>{}</a>\",\n                self.checks_url,\n                self.check_display_name)\n        return params\n\n    @property\n    def formatted_user(self):\n        return format_html(\n            u\"<a href='{}' class='user-name'>{}</a>\",\n            self.profile_url,\n            self.display_name)\n\n    @property\n    def formatted_source(self):\n        return format_html(\n            u\"<a href='{}'>{}</a>\",\n            self.unit_url,\n            self.unit_source)\n\n    @property\n    def action_type(self):\n        return self.action[\"type\"]\n\n    @property\n    def translation_action_type(self):\n        return self.action.get(\"translation_action_type\")\n\n    @property\n    def message(self):\n        msg = \"\"\n        params = self.params\n        if (self.action_type == 2):\n            msg = _('%(user)s removed translation for %(source)s', params)\n        if (self.action_type == 3):\n            msg = _('%(user)s accepted suggestion for %(source)s', params)\n        if (self.action_type == 4):\n            msg = _('%(user)s uploaded file', params)\n        if (self.action_type == 6):\n            msg = _('%(user)s muted %(check)s for %(source)s', params)\n        if (self.action_type == 7):\n            msg = _('%(user)s unmuted %(check)s for %(source)s', params)\n        if (self.action_type == 8):\n            msg = _('%(user)s added suggestion for %(source)s', params)\n        if (self.action_type == 9):\n            msg = _('%(user)s rejected suggestion for %(source)s', params)\n        if (self.action_type in [1, 5]):\n            if self.translation_action_type == 0:\n                msg = _('%(user)s translated %(source)s', params)\n            if self.translation_action_type == 1:\n                msg = _('%(user)s edited %(source)s', params)\n            if self.translation_action_type == 2:\n                msg = _('%(user)s pre-translated %(source)s', params)\n            if self.translation_action_type == 3:\n                msg = _('%(user)s removed translation for %(source)s', params)\n            if self.translation_action_type == 4:\n                msg = _('%(user)s reviewed %(source)s', params)\n            if self.translation_action_type == 5:\n                msg = _('%(user)s marked as needs work %(source)s', params)\n        return mark_safe(msg)\n\n\nclass ChecksDisplay(object):\n\n    def __init__(self, context):\n        self.context = context\n\n    @property\n    def check_schema(self):\n        return get_qualitycheck_list(self.context)\n\n    @cached_property\n    def check_data(self):\n        return self.context.data_tool.get_checks()\n\n    @property\n    def checks_by_category(self):\n        _checks = []\n        for check in self.check_schema:\n            if check[\"code\"] not in self.check_data:\n                continue\n            check[\"count\"] = self.check_data[check[\"code\"]]\n            check[\"count_display\"] = formatter.number(check[\"count\"])\n            _checks.append(check)\n        return _checks\n\n\nclass StatsDisplay(object):\n\n    def __init__(self, context, stats=None):\n        self.context = context\n        self._stats = stats\n\n    @staticmethod\n    def make_display_stat(d, keys=[\"total\", \"critical\", \"incomplete\",\n                                   \"suggestions\", \"fuzzy\", \"untranslated\"]):\n        assert isinstance(d, dict)\n        for k in keys:\n            if k in d:\n                d[k + '_display'] = formatter.number(d[k])\n\n    @cached_property\n    def stat_data(self):\n        if self._stats is not None:\n            return self._stats\n        return self.context.data_tool.get_stats()\n\n    @cached_property\n    def stats(self):\n        stats = self.stat_data\n        self.add_children_info(stats)\n        self.make_display_stat(stats)\n        if stats.get(\"last_submission\"):\n            stats[\"last_submission\"][\"msg\"] = (\n                self.get_action_message(stats[\"last_submission\"]))\n        return stats\n\n    def add_children_info(self, stats):\n        for k, child in stats[\"children\"].items():\n            child[\"incomplete\"] = child[\"total\"] - child[\"translated\"]\n            child[\"untranslated\"] = child[\"total\"] - child[\"translated\"]\n            self.make_display_stat(child)\n\n    def get_action_message(self, action):\n        return ActionDisplay(action).message\n", "path": "pootle/core/views/display.py"}]}