prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Inconsistent data on Admin Statistics end points
  **I'm submitting a ...**  (check one with "x")
  - [x] bug report
  - [ ] feature request
  - [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server
  
  **Current behavior:**
  <!-- Describe how the bug manifests. -->
  The admin statistics end points return various stats about events, users etc.
  Currently they are completely out of sync with the database.
  For instance, the `admin/statisitics/events` returns 
  ![image](https://user-images.githubusercontent.com/17252805/39888957-1a5daf72-54b4-11e8-934c-1d77a9ab66b7.png)
  
  Where as the actual event count when generically querying for events is 92:
  ![image](https://user-images.githubusercontent.com/17252805/39889011-44af3d9a-54b4-11e8-8fb8-c45b0cef175d.png)
  
  **Expected behavior:**
  <!-- Describe what the behavior would be without the bug. -->
  The counts should be consistent.
  
  </issue>
  <code>
  [start of app/api/schema/admin_statistics_schema/events.py]
  1 from marshmallow_jsonapi.flask import Schema
  2 from marshmallow_jsonapi import fields
  3 from app.models.event import Event
  4 from app.api.helpers.db import get_count
  5 from app.api.helpers.utilities import dasherize
  6 from datetime import datetime
  7 import pytz
  8 
  9 
  10 class AdminStatisticsEventSchema(Schema):
  11     """
  12     Api schema
  13     """
  14     class Meta:
  15         """
  16         Meta class
  17         """
  18         type_ = 'admin-statistics-event'
  19         self_view = 'v1.admin_statistics_event_detail'
  20         inflect = dasherize
  21 
  22     id = fields.String()
  23     draft = fields.Method("events_draft_count")
  24     published = fields.Method("events_published_count")
  25     past = fields.Method("events_past_count")
  26 
  27     def events_draft_count(self, obj):
  28         return get_count(Event.query.filter_by(state='draft'))
  29 
  30     def events_published_count(self, obj):
  31         return get_count(Event.query.filter_by(state='published'))
  32 
  33     def events_past_count(self, obj):
  34         return get_count(Event.query.filter(Event.ends_at < datetime.now(pytz.utc)))
  35
  [end of app/api/schema/admin_statistics_schema/events.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/app/api/schema/admin_statistics_schema/events.py b/app/api/schema/admin_statistics_schema/events.py
  --- a/app/api/schema/admin_statistics_schema/events.py
  +++ b/app/api/schema/admin_statistics_schema/events.py
  @@ -25,10 +25,12 @@
       past = fields.Method("events_past_count")
   
       def events_draft_count(self, obj):
  -        return get_count(Event.query.filter_by(state='draft'))
  +        events = Event.query.filter(Event.ends_at > datetime.now(pytz.utc))
  +        return get_count(events.filter_by(state='draft'))
   
       def events_published_count(self, obj):
  -        return get_count(Event.query.filter_by(state='published'))
  +        events = Event.query.filter(Event.ends_at > datetime.now(pytz.utc))
  +        return get_count(events.filter_by(state='published'))
   
       def events_past_count(self, obj):
           return get_count(Event.query.filter(Event.ends_at < datetime.now(pytz.utc)))
  
verification_info: {"golden_diff": "diff --git a/app/api/schema/admin_statistics_schema/events.py b/app/api/schema/admin_statistics_schema/events.py\n--- a/app/api/schema/admin_statistics_schema/events.py\n+++ b/app/api/schema/admin_statistics_schema/events.py\n@@ -25,10 +25,12 @@\n     past = fields.Method(\"events_past_count\")\n \n     def events_draft_count(self, obj):\n-        return get_count(Event.query.filter_by(state='draft'))\n+        events = Event.query.filter(Event.ends_at > datetime.now(pytz.utc))\n+        return get_count(events.filter_by(state='draft'))\n \n     def events_published_count(self, obj):\n-        return get_count(Event.query.filter_by(state='published'))\n+        events = Event.query.filter(Event.ends_at > datetime.now(pytz.utc))\n+        return get_count(events.filter_by(state='published'))\n \n     def events_past_count(self, obj):\n         return get_count(Event.query.filter(Event.ends_at < datetime.now(pytz.utc)))\n", "issue": "Inconsistent data on Admin Statistics end points\n**I'm submitting a ...**  (check one with \"x\")\r\n- [x] bug report\r\n- [ ] feature request\r\n- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server\r\n\r\n**Current behavior:**\r\n<!-- Describe how the bug manifests. -->\r\nThe admin statistics end points return various stats about events, users etc.\r\nCurrently they are completely out of sync with the database.\r\nFor instance, the `admin/statisitics/events` returns \r\n![image](https://user-images.githubusercontent.com/17252805/39888957-1a5daf72-54b4-11e8-934c-1d77a9ab66b7.png)\r\n\r\nWhere as the actual event count when generically querying for events is 92:\r\n![image](https://user-images.githubusercontent.com/17252805/39889011-44af3d9a-54b4-11e8-8fb8-c45b0cef175d.png)\r\n\r\n**Expected behavior:**\r\n<!-- Describe what the behavior would be without the bug. -->\r\nThe counts should be consistent.\n", "before_files": [{"content": "from marshmallow_jsonapi.flask import Schema\nfrom marshmallow_jsonapi import fields\nfrom app.models.event import Event\nfrom app.api.helpers.db import get_count\nfrom app.api.helpers.utilities import dasherize\nfrom datetime import datetime\nimport pytz\n\n\nclass AdminStatisticsEventSchema(Schema):\n    \"\"\"\n    Api schema\n    \"\"\"\n    class Meta:\n        \"\"\"\n        Meta class\n        \"\"\"\n        type_ = 'admin-statistics-event'\n        self_view = 'v1.admin_statistics_event_detail'\n        inflect = dasherize\n\n    id = fields.String()\n    draft = fields.Method(\"events_draft_count\")\n    published = fields.Method(\"events_published_count\")\n    past = fields.Method(\"events_past_count\")\n\n    def events_draft_count(self, obj):\n        return get_count(Event.query.filter_by(state='draft'))\n\n    def events_published_count(self, obj):\n        return get_count(Event.query.filter_by(state='published'))\n\n    def events_past_count(self, obj):\n        return get_count(Event.query.filter(Event.ends_at < datetime.now(pytz.utc)))\n", "path": "app/api/schema/admin_statistics_schema/events.py"}]}