prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Depenendency Upgrades
  The following dependencies have to be upgraded
  
  - urllib3 = ">=1.24.2"
  - SQLAlchemy = ">=1.3.0"
  - Jinja2 = ">=2.10.1"
  - marshmallow = ">=2.15.1"
  
  </issue>
  <code>
  [start of app/api/admin_sales/locations.py]
  1 from marshmallow_jsonapi import fields
  2 from marshmallow_jsonapi.flask import Schema
  3 from flask_rest_jsonapi import ResourceList
  4 from sqlalchemy import func
  5 from app.api.helpers.utilities import dasherize
  6 
  7 from app.api.bootstrap import api
  8 from app.models import db
  9 from app.models.event import Event
  10 from app.models.order import Order, OrderTicket
  11 
  12 
  13 def sales_per_location_by_status(status):
  14     return db.session.query(
  15         Event.location_name.label('location'),
  16         func.sum(Order.amount).label(status + '_sales'),
  17         func.sum(OrderTicket.quantity).label(status + '_tickets')) \
  18                      .outerjoin(Order) \
  19                      .outerjoin(OrderTicket) \
  20                      .filter(Event.id == Order.event_id) \
  21                      .filter(Order.status == status) \
  22                      .group_by(Event.location_name, Order.status) \
  23                      .cte()
  24 
  25 
  26 class AdminSalesByLocationSchema(Schema):
  27     """
  28     Sales summarized by location
  29 
  30     Provides
  31         location name,
  32         count of tickets and total sales for orders grouped by status
  33     """
  34 
  35     class Meta:
  36         type_ = 'admin-sales-by-location'
  37         self_view = 'v1.admin_sales_by_location'
  38         inflect = dasherize
  39 
  40     id = fields.String()
  41     location_name = fields.String()
  42     sales = fields.Method('calc_sales')
  43 
  44     @staticmethod
  45     def calc_sales(obj):
  46         """
  47         Returns sales (dictionary with total sales and ticket count) for
  48         placed, completed and pending orders
  49         """
  50         res = {'placed': {}, 'completed': {}, 'pending': {}}
  51         res['placed']['sales_total'] = obj.placed_sales or 0
  52         res['placed']['ticket_count'] = obj.placed_tickets or 0
  53         res['completed']['sales_total'] = obj.completed_sales or 0
  54         res['completed']['ticket_count'] = obj.completed_tickets or 0
  55         res['pending']['sales_total'] = obj.pending_sales or 0
  56         res['pending']['ticket_count'] = obj.pending_tickets or 0
  57 
  58         return res
  59 
  60 
  61 class AdminSalesByLocationList(ResourceList):
  62     """
  63     Resource for sales by location. Joins event locations and orders and
  64     subsequently accumulates sales by status
  65     """
  66 
  67     def query(self, _):
  68         locations = self.session.query(
  69             Event.location_name,
  70             Event.location_name.label('id')) \
  71                 .group_by(Event.location_name) \
  72                 .filter(Event.location_name.isnot(None)) \
  73                 .cte()
  74 
  75         pending = sales_per_location_by_status('pending')
  76         completed = sales_per_location_by_status('completed')
  77         placed = sales_per_location_by_status('placed')
  78 
  79         return self.session.query(locations, pending, completed, placed) \
  80                            .outerjoin(pending, pending.c.location == locations.c.location_name) \
  81                            .outerjoin(completed, completed.c.location == locations.c.location_name) \
  82                            .outerjoin(placed, placed.c.location == locations.c.location_name)
  83 
  84     methods = ['GET']
  85     decorators = (api.has_permission('is_admin'), )
  86     schema = AdminSalesByLocationSchema
  87     data_layer = {
  88         'model': Event,
  89         'session': db.session,
  90         'methods': {
  91             'query': query
  92         }
  93     }
  94
  [end of app/api/admin_sales/locations.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/admin_sales/locations.py b/app/api/admin_sales/locations.py
  --- a/app/api/admin_sales/locations.py
  +++ b/app/api/admin_sales/locations.py
  @@ -15,8 +15,8 @@
           Event.location_name.label('location'),
           func.sum(Order.amount).label(status + '_sales'),
           func.sum(OrderTicket.quantity).label(status + '_tickets')) \
  -                     .outerjoin(Order) \
  -                     .outerjoin(OrderTicket) \
  +                     .outerjoin(Order, Order.event_id == Event.id) \
  +                     .outerjoin(OrderTicket, OrderTicket.order_id == Order.id) \
                        .filter(Event.id == Order.event_id) \
                        .filter(Order.status == status) \
                        .group_by(Event.location_name, Order.status) \
  
verification_info: {"golden_diff": "diff --git a/app/api/admin_sales/locations.py b/app/api/admin_sales/locations.py\n--- a/app/api/admin_sales/locations.py\n+++ b/app/api/admin_sales/locations.py\n@@ -15,8 +15,8 @@\n         Event.location_name.label('location'),\n         func.sum(Order.amount).label(status + '_sales'),\n         func.sum(OrderTicket.quantity).label(status + '_tickets')) \\\n-                     .outerjoin(Order) \\\n-                     .outerjoin(OrderTicket) \\\n+                     .outerjoin(Order, Order.event_id == Event.id) \\\n+                     .outerjoin(OrderTicket, OrderTicket.order_id == Order.id) \\\n                      .filter(Event.id == Order.event_id) \\\n                      .filter(Order.status == status) \\\n                      .group_by(Event.location_name, Order.status) \\\n", "issue": "Depenendency Upgrades\nThe following dependencies have to be upgraded\r\n\r\n- urllib3 = \">=1.24.2\"\r\n- SQLAlchemy = \">=1.3.0\"\r\n- Jinja2 = \">=2.10.1\"\r\n- marshmallow = \">=2.15.1\"\n", "before_files": [{"content": "from marshmallow_jsonapi import fields\nfrom marshmallow_jsonapi.flask import Schema\nfrom flask_rest_jsonapi import ResourceList\nfrom sqlalchemy import func\nfrom app.api.helpers.utilities import dasherize\n\nfrom app.api.bootstrap import api\nfrom app.models import db\nfrom app.models.event import Event\nfrom app.models.order import Order, OrderTicket\n\n\ndef sales_per_location_by_status(status):\n    return db.session.query(\n        Event.location_name.label('location'),\n        func.sum(Order.amount).label(status + '_sales'),\n        func.sum(OrderTicket.quantity).label(status + '_tickets')) \\\n                     .outerjoin(Order) \\\n                     .outerjoin(OrderTicket) \\\n                     .filter(Event.id == Order.event_id) \\\n                     .filter(Order.status == status) \\\n                     .group_by(Event.location_name, Order.status) \\\n                     .cte()\n\n\nclass AdminSalesByLocationSchema(Schema):\n    \"\"\"\n    Sales summarized by location\n\n    Provides\n        location name,\n        count of tickets and total sales for orders grouped by status\n    \"\"\"\n\n    class Meta:\n        type_ = 'admin-sales-by-location'\n        self_view = 'v1.admin_sales_by_location'\n        inflect = dasherize\n\n    id = fields.String()\n    location_name = fields.String()\n    sales = fields.Method('calc_sales')\n\n    @staticmethod\n    def calc_sales(obj):\n        \"\"\"\n        Returns sales (dictionary with total sales and ticket count) for\n        placed, completed and pending orders\n        \"\"\"\n        res = {'placed': {}, 'completed': {}, 'pending': {}}\n        res['placed']['sales_total'] = obj.placed_sales or 0\n        res['placed']['ticket_count'] = obj.placed_tickets or 0\n        res['completed']['sales_total'] = obj.completed_sales or 0\n        res['completed']['ticket_count'] = obj.completed_tickets or 0\n        res['pending']['sales_total'] = obj.pending_sales or 0\n        res['pending']['ticket_count'] = obj.pending_tickets or 0\n\n        return res\n\n\nclass AdminSalesByLocationList(ResourceList):\n    \"\"\"\n    Resource for sales by location. Joins event locations and orders and\n    subsequently accumulates sales by status\n    \"\"\"\n\n    def query(self, _):\n        locations = self.session.query(\n            Event.location_name,\n            Event.location_name.label('id')) \\\n                .group_by(Event.location_name) \\\n                .filter(Event.location_name.isnot(None)) \\\n                .cte()\n\n        pending = sales_per_location_by_status('pending')\n        completed = sales_per_location_by_status('completed')\n        placed = sales_per_location_by_status('placed')\n\n        return self.session.query(locations, pending, completed, placed) \\\n                           .outerjoin(pending, pending.c.location == locations.c.location_name) \\\n                           .outerjoin(completed, completed.c.location == locations.c.location_name) \\\n                           .outerjoin(placed, placed.c.location == locations.c.location_name)\n\n    methods = ['GET']\n    decorators = (api.has_permission('is_admin'), )\n    schema = AdminSalesByLocationSchema\n    data_layer = {\n        'model': Event,\n        'session': db.session,\n        'methods': {\n            'query': query\n        }\n    }\n", "path": "app/api/admin_sales/locations.py"}]}