We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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"

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/api/admin_sales/locations.py`
Content:
```
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 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/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) \

{"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"}], "after_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, 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                     .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"}]}