prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  update_stores' last updated date doesn't tickle up to project overview/language list
  When updating against templates, the /projects/projectname/ listing doesn't reflect the **last update**, **unless** the update affected a file in the **toplevel** dir.
  
  Within a language overview (/lang/projectname), changes deep in a directory hierarchy will also affect the  parent directory's last-change date.
  
  using pootle 2.8.0b5 (TDF)
  
  screenshots to clarify. overview lists last update as e.g. 3 weeks ago:
  ![bildschirmfoto von 2016-12-22 16 40 21](https://cloud.githubusercontent.com/assets/477936/21430954/acb2d028-c865-11e6-84ec-0784563abba2.png)
  
  drilling down to the language reveals that the files in xmlsecurity actually had been updated only 8 hours ago (in fact xmlsecurity/uiconfig/ui.po)
  ![bildschirmfoto von 2016-12-22 16 41 26](https://cloud.githubusercontent.com/assets/477936/21431071/27d3ab2e-c866-11e6-8350-4690fe89cc03.png)
  
  (also sorting by the last updated is not working properly, goes from 10months to 8 hours, to 3weeks…)   
  
  </issue>
  <code>
  [start of pootle/apps/pootle_data/project_data.py]
  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 .utils import RelatedStoresDataTool, RelatedTPsDataTool
  10 
  11 
  12 class ProjectDataTool(RelatedTPsDataTool):
  13     """Retrieves aggregate stats for a Project"""
  14 
  15     cache_key_name = "project"
  16 
  17     def filter_data(self, qs):
  18         return qs.filter(tp__project=self.context)
  19 
  20 
  21 class ProjectResourceDataTool(RelatedStoresDataTool):
  22     group_by = ("store__translation_project__language__code", )
  23     cache_key_name = "project_resource"
  24 
  25     @property
  26     def project_path(self):
  27         return (
  28             "/%s%s"
  29             % (self.project_code, self.tp_path))
  30 
  31     @property
  32     def tp_path(self):
  33         return (
  34             "/%s%s"
  35             % (self.dir_path,
  36                self.filename))
  37 
  38     def filter_data(self, qs):
  39         return (
  40             qs.filter(store__translation_project__project__code=self.project_code)
  41               .filter(store__tp_path__startswith=self.tp_path))
  42 
  43     @property
  44     def context_name(self):
  45         return "/projects%s" % self.project_path
  46 
  47 
  48 class ProjectSetDataTool(RelatedTPsDataTool):
  49     group_by = ("tp__project__code", )
  50     cache_key_name = "projects"
  51 
  52     def get_root_child_path(self, child):
  53         return child[self.group_by[0]]
  54 
  55     @property
  56     def context_name(self):
  57         return "ALL"
  58
  [end of pootle/apps/pootle_data/project_data.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pootle/apps/pootle_data/project_data.py b/pootle/apps/pootle_data/project_data.py
  --- a/pootle/apps/pootle_data/project_data.py
  +++ b/pootle/apps/pootle_data/project_data.py
  @@ -6,6 +6,8 @@
   # or later license. See the LICENSE file for a copy of the license and the
   # AUTHORS file for copyright and authorship information.
   
  +from pootle.core.delegate import revision
  +
   from .utils import RelatedStoresDataTool, RelatedTPsDataTool
   
   
  @@ -17,6 +19,11 @@
       def filter_data(self, qs):
           return qs.filter(tp__project=self.context)
   
  +    @property
  +    def rev_cache_key(self):
  +        return revision.get(
  +            self.context.__class__)(self.context.directory).get(key="stats")
  +
   
   class ProjectResourceDataTool(RelatedStoresDataTool):
       group_by = ("store__translation_project__language__code", )
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_data/project_data.py b/pootle/apps/pootle_data/project_data.py\n--- a/pootle/apps/pootle_data/project_data.py\n+++ b/pootle/apps/pootle_data/project_data.py\n@@ -6,6 +6,8 @@\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 \n+from pootle.core.delegate import revision\n+\n from .utils import RelatedStoresDataTool, RelatedTPsDataTool\n \n \n@@ -17,6 +19,11 @@\n     def filter_data(self, qs):\n         return qs.filter(tp__project=self.context)\n \n+    @property\n+    def rev_cache_key(self):\n+        return revision.get(\n+            self.context.__class__)(self.context.directory).get(key=\"stats\")\n+\n \n class ProjectResourceDataTool(RelatedStoresDataTool):\n     group_by = (\"store__translation_project__language__code\", )\n", "issue": "update_stores' last updated date doesn't tickle up to project overview/language list\nWhen updating against templates, the /projects/projectname/ listing doesn't reflect the **last update**, **unless** the update affected a file in the **toplevel** dir.\r\n\r\nWithin a language overview (/lang/projectname), changes deep in a directory hierarchy will also affect the  parent directory's last-change date.\r\n\r\nusing pootle 2.8.0b5 (TDF)\r\n\r\nscreenshots to clarify. overview lists last update as e.g. 3 weeks ago:\r\n![bildschirmfoto von 2016-12-22 16 40 21](https://cloud.githubusercontent.com/assets/477936/21430954/acb2d028-c865-11e6-84ec-0784563abba2.png)\r\n\r\ndrilling down to the language reveals that the files in xmlsecurity actually had been updated only 8 hours ago (in fact xmlsecurity/uiconfig/ui.po)\r\n![bildschirmfoto von 2016-12-22 16 41 26](https://cloud.githubusercontent.com/assets/477936/21431071/27d3ab2e-c866-11e6-8350-4690fe89cc03.png)\r\n\r\n(also sorting by the last updated is not working properly, goes from 10months to 8 hours, to 3weeks\u2026)   \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 .utils import RelatedStoresDataTool, RelatedTPsDataTool\n\n\nclass ProjectDataTool(RelatedTPsDataTool):\n    \"\"\"Retrieves aggregate stats for a Project\"\"\"\n\n    cache_key_name = \"project\"\n\n    def filter_data(self, qs):\n        return qs.filter(tp__project=self.context)\n\n\nclass ProjectResourceDataTool(RelatedStoresDataTool):\n    group_by = (\"store__translation_project__language__code\", )\n    cache_key_name = \"project_resource\"\n\n    @property\n    def project_path(self):\n        return (\n            \"/%s%s\"\n            % (self.project_code, self.tp_path))\n\n    @property\n    def tp_path(self):\n        return (\n            \"/%s%s\"\n            % (self.dir_path,\n               self.filename))\n\n    def filter_data(self, qs):\n        return (\n            qs.filter(store__translation_project__project__code=self.project_code)\n              .filter(store__tp_path__startswith=self.tp_path))\n\n    @property\n    def context_name(self):\n        return \"/projects%s\" % self.project_path\n\n\nclass ProjectSetDataTool(RelatedTPsDataTool):\n    group_by = (\"tp__project__code\", )\n    cache_key_name = \"projects\"\n\n    def get_root_child_path(self, child):\n        return child[self.group_by[0]]\n\n    @property\n    def context_name(self):\n        return \"ALL\"\n", "path": "pootle/apps/pootle_data/project_data.py"}]}