We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ebola page: loading second page of datasets reloads to top of page
Would it be easy to have it load the page at the `Datasets [41]` line?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py`
Content:
```
1 '''
2 Created on Nov 3, 2014
3 
4 @author: alexandru-m-g
5 '''
6 
7 import logging
8 import datetime as dt
9 import decimal
10 
11 import pylons.config as config
12 
13 import ckan.lib.base as base
14 import ckan.logic as logic
15 import ckan.model as model
16 import ckan.common as common
17 import ckan.lib.helpers as h
18 
19 render = base.render
20 get_action = logic.get_action
21 c = common.c
22 request = common.request
23 _ = common._
24 
25 Decimal = decimal.Decimal
26 
27 log = logging.getLogger(__name__)
28 
29 
30 class CrisisController(base.BaseController):
31 
32     def show(self):
33 
34         context = {'model': model, 'session': model.Session,
35                    'user': c.user or c.author, 'for_view': True,
36                    'auth_user_obj': c.userobj}
37 
38         datastore_resource_id = self._get_datastore_resource_id(
39             context, config.get('hdx.crisis.ebola_dataset', None), config.get('hdx.crisis.ebola_resource_title', None))
40         if datastore_resource_id:
41             c.top_line_items = self._get_top_line_items(
42                 context, datastore_resource_id)
43 
44         limit = 25
45         c.q = u'ebola'
46 
47         page = int(request.params.get('page', 1))
48         data_dict = {'sort': u'metadata_modified desc',
49                      'fq': '+dataset_type:dataset',
50                      'rows': limit,
51                      'q': c.q,
52                      'start': (page - 1) * limit
53                      }
54         query = get_action("package_search")(context, data_dict)
55 
56         def pager_url(q=None, page=None):
57             return h.url_for('show_crisis', page=page)
58 
59         c.page = h.Page(
60             collection=query['results'],
61             page=page,
62             url=pager_url,
63             item_count=query['count'],
64             items_per_page=limit
65         )
66         c.items = query['results']
67         c.item_count = query['count']
68 
69         c.other_links = {}
70         c.other_links['show_more'] = h.url_for(
71             "search", **{'q': u'ebola', 'sort': u'metadata_modified desc',
72                          'ext_indicator': '0'})
73 
74         return render('crisis/crisis.html')
75 
76     def _get_decimal_value(self, value):
77         decimal_value = Decimal(str(value)).quantize(
78             Decimal('.1'), rounding=decimal.ROUND_HALF_UP)
79         return decimal_value
80 
81     def _format_results(self, result):
82         for r in result['records']:
83             d = dt.datetime.strptime(r[u'latest_date'], '%Y-%m-%dT%H:%M:%S')
84             r[u'latest_date'] = dt.datetime.strftime(d, '%b %d, %Y')
85 
86             modified_value = r[u'value']
87             if r[u'units'] == 'ratio':
88                 modified_value *= 100.0
89             elif r[u'units'] == 'million':
90                 modified_value /= 1000000.0
91 
92             int_value = int(modified_value)
93             if int_value == modified_value:
94                 r[u'formatted_value'] = '{:,}'.format(int_value)
95             else:
96                 if r[u'units'] == 'ratio':
97                     r[u'formatted_value'] = '{:,.1f}'.format(
98                         self._get_decimal_value(modified_value))
99                 elif r[u'units'] == 'million':
100                     r[u'formatted_value'] = '{:,.1f}'.format(
101                         self._get_decimal_value(modified_value))
102                     #r[u'formatted_value'] += ' ' + _('million')
103 
104     def _get_top_line_items(self, context, datastore_resource_id):
105         modified_context = dict(context)
106         modified_context['ignore_auth'] = True
107         result = get_action('datastore_search')(
108             modified_context, {'resource_id': datastore_resource_id})
109         if 'records' in result:
110             self._format_results(result)
111             return result['records']
112         return []
113 
114     def _get_datastore_resource_id(self, context, dataset_id, resource_name):
115         try:
116             modified_context = dict(context)
117             modified_context['ignore_auth'] = True
118             dataset = get_action('package_show')(
119                 modified_context, {'id': dataset_id})
120 
121             if 'resources' in dataset:
122                 for r in dataset['resources']:
123                     if 'datastore_active' in r and r['datastore_active'] \
124                             and r['name'] == resource_name:
125                         return r['id']
126             return None
127         except:
128             log.warning('No dataset with id ' + dataset_id)
129             return None
130
```
--- 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/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py b/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py
--- a/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py
+++ b/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py
@@ -54,7 +54,8 @@
         query = get_action("package_search")(context, data_dict)
 
         def pager_url(q=None, page=None):
-            return h.url_for('show_crisis', page=page)
+            url = h.url_for('show_crisis', page=page) + '#datasets-section'
+            return url
 
         c.page = h.Page(
             collection=query['results'],

{"golden_diff": "diff --git a/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py b/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py\n--- a/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py\n+++ b/ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py\n@@ -54,7 +54,8 @@\n         query = get_action(\"package_search\")(context, data_dict)\n \n         def pager_url(q=None, page=None):\n-            return h.url_for('show_crisis', page=page)\n+            url = h.url_for('show_crisis', page=page) + '#datasets-section'\n+            return url\n \n         c.page = h.Page(\n             collection=query['results'],\n", "issue": "Ebola page: loading second page of datasets reloads to top of page\nWould it be easy to have it load the page at the `Datasets [41]` line?\n\n", "before_files": [{"content": "'''\nCreated on Nov 3, 2014\n\n@author: alexandru-m-g\n'''\n\nimport logging\nimport datetime as dt\nimport decimal\n\nimport pylons.config as config\n\nimport ckan.lib.base as base\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.common as common\nimport ckan.lib.helpers as h\n\nrender = base.render\nget_action = logic.get_action\nc = common.c\nrequest = common.request\n_ = common._\n\nDecimal = decimal.Decimal\n\nlog = logging.getLogger(__name__)\n\n\nclass CrisisController(base.BaseController):\n\n    def show(self):\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True,\n                   'auth_user_obj': c.userobj}\n\n        datastore_resource_id = self._get_datastore_resource_id(\n            context, config.get('hdx.crisis.ebola_dataset', None), config.get('hdx.crisis.ebola_resource_title', None))\n        if datastore_resource_id:\n            c.top_line_items = self._get_top_line_items(\n                context, datastore_resource_id)\n\n        limit = 25\n        c.q = u'ebola'\n\n        page = int(request.params.get('page', 1))\n        data_dict = {'sort': u'metadata_modified desc',\n                     'fq': '+dataset_type:dataset',\n                     'rows': limit,\n                     'q': c.q,\n                     'start': (page - 1) * limit\n                     }\n        query = get_action(\"package_search\")(context, data_dict)\n\n        def pager_url(q=None, page=None):\n            return h.url_for('show_crisis', page=page)\n\n        c.page = h.Page(\n            collection=query['results'],\n            page=page,\n            url=pager_url,\n            item_count=query['count'],\n            items_per_page=limit\n        )\n        c.items = query['results']\n        c.item_count = query['count']\n\n        c.other_links = {}\n        c.other_links['show_more'] = h.url_for(\n            \"search\", **{'q': u'ebola', 'sort': u'metadata_modified desc',\n                         'ext_indicator': '0'})\n\n        return render('crisis/crisis.html')\n\n    def _get_decimal_value(self, value):\n        decimal_value = Decimal(str(value)).quantize(\n            Decimal('.1'), rounding=decimal.ROUND_HALF_UP)\n        return decimal_value\n\n    def _format_results(self, result):\n        for r in result['records']:\n            d = dt.datetime.strptime(r[u'latest_date'], '%Y-%m-%dT%H:%M:%S')\n            r[u'latest_date'] = dt.datetime.strftime(d, '%b %d, %Y')\n\n            modified_value = r[u'value']\n            if r[u'units'] == 'ratio':\n                modified_value *= 100.0\n            elif r[u'units'] == 'million':\n                modified_value /= 1000000.0\n\n            int_value = int(modified_value)\n            if int_value == modified_value:\n                r[u'formatted_value'] = '{:,}'.format(int_value)\n            else:\n                if r[u'units'] == 'ratio':\n                    r[u'formatted_value'] = '{:,.1f}'.format(\n                        self._get_decimal_value(modified_value))\n                elif r[u'units'] == 'million':\n                    r[u'formatted_value'] = '{:,.1f}'.format(\n                        self._get_decimal_value(modified_value))\n                    #r[u'formatted_value'] += ' ' + _('million')\n\n    def _get_top_line_items(self, context, datastore_resource_id):\n        modified_context = dict(context)\n        modified_context['ignore_auth'] = True\n        result = get_action('datastore_search')(\n            modified_context, {'resource_id': datastore_resource_id})\n        if 'records' in result:\n            self._format_results(result)\n            return result['records']\n        return []\n\n    def _get_datastore_resource_id(self, context, dataset_id, resource_name):\n        try:\n            modified_context = dict(context)\n            modified_context['ignore_auth'] = True\n            dataset = get_action('package_show')(\n                modified_context, {'id': dataset_id})\n\n            if 'resources' in dataset:\n                for r in dataset['resources']:\n                    if 'datastore_active' in r and r['datastore_active'] \\\n                            and r['name'] == resource_name:\n                        return r['id']\n            return None\n        except:\n            log.warning('No dataset with id ' + dataset_id)\n            return None\n", "path": "ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py"}], "after_files": [{"content": "'''\nCreated on Nov 3, 2014\n\n@author: alexandru-m-g\n'''\n\nimport logging\nimport datetime as dt\nimport decimal\n\nimport pylons.config as config\n\nimport ckan.lib.base as base\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.common as common\nimport ckan.lib.helpers as h\n\nrender = base.render\nget_action = logic.get_action\nc = common.c\nrequest = common.request\n_ = common._\n\nDecimal = decimal.Decimal\n\nlog = logging.getLogger(__name__)\n\n\nclass CrisisController(base.BaseController):\n\n    def show(self):\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True,\n                   'auth_user_obj': c.userobj}\n\n        datastore_resource_id = self._get_datastore_resource_id(\n            context, config.get('hdx.crisis.ebola_dataset', None), config.get('hdx.crisis.ebola_resource_title', None))\n        if datastore_resource_id:\n            c.top_line_items = self._get_top_line_items(\n                context, datastore_resource_id)\n\n        limit = 25\n        c.q = u'ebola'\n\n        page = int(request.params.get('page', 1))\n        data_dict = {'sort': u'metadata_modified desc',\n                     'fq': '+dataset_type:dataset',\n                     'rows': limit,\n                     'q': c.q,\n                     'start': (page - 1) * limit\n                     }\n        query = get_action(\"package_search\")(context, data_dict)\n\n        def pager_url(q=None, page=None):\n            url = h.url_for('show_crisis', page=page) + '#datasets-section'\n            return url\n\n        c.page = h.Page(\n            collection=query['results'],\n            page=page,\n            url=pager_url,\n            item_count=query['count'],\n            items_per_page=limit\n        )\n        c.items = query['results']\n        c.item_count = query['count']\n\n        c.other_links = {}\n        c.other_links['show_more'] = h.url_for(\n            \"search\", **{'q': u'ebola', 'sort': u'metadata_modified desc',\n                         'ext_indicator': '0'})\n\n        return render('crisis/crisis.html')\n\n    def _get_decimal_value(self, value):\n        decimal_value = Decimal(str(value)).quantize(\n            Decimal('.1'), rounding=decimal.ROUND_HALF_UP)\n        return decimal_value\n\n    def _format_results(self, result):\n        for r in result['records']:\n            d = dt.datetime.strptime(r[u'latest_date'], '%Y-%m-%dT%H:%M:%S')\n            r[u'latest_date'] = dt.datetime.strftime(d, '%b %d, %Y')\n\n            modified_value = r[u'value']\n            if r[u'units'] == 'ratio':\n                modified_value *= 100.0\n            elif r[u'units'] == 'million':\n                modified_value /= 1000000.0\n\n            int_value = int(modified_value)\n            if int_value == modified_value:\n                r[u'formatted_value'] = '{:,}'.format(int_value)\n            else:\n                if r[u'units'] == 'ratio':\n                    r[u'formatted_value'] = '{:,.1f}'.format(\n                        self._get_decimal_value(modified_value))\n                elif r[u'units'] == 'million':\n                    r[u'formatted_value'] = '{:,.1f}'.format(\n                        self._get_decimal_value(modified_value))\n                    #r[u'formatted_value'] += ' ' + _('million')\n\n    def _get_top_line_items(self, context, datastore_resource_id):\n        modified_context = dict(context)\n        modified_context['ignore_auth'] = True\n        result = get_action('datastore_search')(\n            modified_context, {'resource_id': datastore_resource_id})\n        if 'records' in result:\n            self._format_results(result)\n            return result['records']\n        return []\n\n    def _get_datastore_resource_id(self, context, dataset_id, resource_name):\n        try:\n            modified_context = dict(context)\n            modified_context['ignore_auth'] = True\n            dataset = get_action('package_show')(\n                modified_context, {'id': dataset_id})\n\n            if 'resources' in dataset:\n                for r in dataset['resources']:\n                    if 'datastore_active' in r and r['datastore_active'] \\\n                            and r['name'] == resource_name:\n                        return r['id']\n            return None\n        except:\n            log.warning('No dataset with id ' + dataset_id)\n            return None\n", "path": "ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py"}]}