prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Ebola Page: make millions and % smaller
  About half the current height looks right.
  
  ![image](https://cloud.githubusercontent.com/assets/1654485/5007241/32010f00-6a4f-11e4-906d-4be38940993f.png)
  
  
  </issue>
  <code>
  [start of ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.py]
  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 of ckanext-hdx_crisis/ckanext/hdx_crisis/controllers/crisis_controller.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/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
  @@ -94,12 +94,12 @@
                   r[u'formatted_value'] = '{:,}'.format(int_value)
               else:
                   if r[u'units'] == 'ratio':
  -                    r[u'formatted_value'] = '{:,.1f}%'.format(
  +                    r[u'formatted_value'] = '{:,.1f}'.format(
                           self._get_decimal_value(modified_value))
                   elif r[u'units'] == 'million':
  -                    r[u'formatted_value'] = '{:,.1f} '.format(
  +                    r[u'formatted_value'] = '{:,.1f}'.format(
                           self._get_decimal_value(modified_value))
  -                    r[u'formatted_value'] += ' ' + _('million')
  +                    #r[u'formatted_value'] += ' ' + _('million')
   
       def _get_top_line_items(self, context, datastore_resource_id):
           modified_context = dict(context)
  
verification_info: {"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@@ -94,12 +94,12 @@\n                 r[u'formatted_value'] = '{:,}'.format(int_value)\n             else:\n                 if r[u'units'] == 'ratio':\n-                    r[u'formatted_value'] = '{:,.1f}%'.format(\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+                    r[u'formatted_value'] = '{:,.1f}'.format(\n                         self._get_decimal_value(modified_value))\n-                    r[u'formatted_value'] += ' ' + _('million')\n+                    #r[u'formatted_value'] += ' ' + _('million')\n \n     def _get_top_line_items(self, context, datastore_resource_id):\n         modified_context = dict(context)\n", "issue": "Ebola Page: make millions and % smaller\nAbout half the current height looks right.\n\n![image](https://cloud.githubusercontent.com/assets/1654485/5007241/32010f00-6a4f-11e4-906d-4be38940993f.png)\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"}]}