prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add to status page the size of Redash's DB
  ```sql
  SELECT pg_size_pretty(pg_total_relation_size('query_results'));
  ```
  
  ```sql
  SELECT pg_size_pretty(pg_database_size('redash'));
  ```
  
  </issue>
  <code>
  [start of redash/monitor.py]
  1 from redash import redis_connection, models, __version__, settings
  2 
  3 
  4 def get_status():
  5     status = {}
  6     info = redis_connection.info()
  7     status['redis_used_memory'] = info['used_memory']
  8     status['redis_used_memory_human'] = info['used_memory_human']
  9     status['version'] = __version__
  10     status['queries_count'] = models.db.session.query(models.Query).count()
  11     if settings.FEATURE_SHOW_QUERY_RESULTS_COUNT:
  12         status['query_results_count'] = models.db.session.query(models.QueryResult).count()
  13         status['unused_query_results_count'] = models.QueryResult.unused().count()
  14     status['dashboards_count'] = models.Dashboard.query.count()
  15     status['widgets_count'] = models.Widget.query.count()
  16 
  17     status['workers'] = []
  18 
  19     status['manager'] = redis_connection.hgetall('redash:status')
  20 
  21     queues = {}
  22     for ds in models.DataSource.query:
  23         for queue in (ds.queue_name, ds.scheduled_queue_name):
  24             queues.setdefault(queue, set())
  25             queues[queue].add(ds.name)
  26 
  27     status['manager']['queues'] = {}
  28     for queue, sources in queues.iteritems():
  29         status['manager']['queues'][queue] = {
  30             'data_sources': ', '.join(sources),
  31             'size': redis_connection.llen(queue)
  32         }
  33     
  34     status['manager']['queues']['celery'] = {
  35         'size': redis_connection.llen('celery'),
  36         'data_sources': ''
  37     }
  38 
  39     return status
  40
  [end of redash/monitor.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/redash/monitor.py b/redash/monitor.py
  --- a/redash/monitor.py
  +++ b/redash/monitor.py
  @@ -1,39 +1,72 @@
   from redash import redis_connection, models, __version__, settings
   
   
  -def get_status():
  -    status = {}
  +def get_redis_status():
       info = redis_connection.info()
  -    status['redis_used_memory'] = info['used_memory']
  -    status['redis_used_memory_human'] = info['used_memory_human']
  -    status['version'] = __version__
  +    return {'redis_used_memory': info['used_memory'], 'redis_used_memory_human': info['used_memory_human']}
  +
  +
  +def get_object_counts():
  +    status = {}
       status['queries_count'] = models.db.session.query(models.Query).count()
       if settings.FEATURE_SHOW_QUERY_RESULTS_COUNT:
           status['query_results_count'] = models.db.session.query(models.QueryResult).count()
           status['unused_query_results_count'] = models.QueryResult.unused().count()
       status['dashboards_count'] = models.Dashboard.query.count()
       status['widgets_count'] = models.Widget.query.count()
  +    return status
   
  -    status['workers'] = []
  -
  -    status['manager'] = redis_connection.hgetall('redash:status')
   
  +def get_queues():
       queues = {}
       for ds in models.DataSource.query:
           for queue in (ds.queue_name, ds.scheduled_queue_name):
               queues.setdefault(queue, set())
               queues[queue].add(ds.name)
   
  -    status['manager']['queues'] = {}
  +    return queues
  +
  +
  +def get_queues_status():
  +    queues = get_queues()
  +
       for queue, sources in queues.iteritems():
  -        status['manager']['queues'][queue] = {
  +        queues[queue] = {
               'data_sources': ', '.join(sources),
               'size': redis_connection.llen(queue)
           }
       
  -    status['manager']['queues']['celery'] = {
  +    queues['celery'] = {
           'size': redis_connection.llen('celery'),
           'data_sources': ''
       }
   
  +    return queues
  +
  +
  +def get_db_sizes():
  +    database_metrics = []
  +    queries = [
  +        ['Query Results Size', "select pg_total_relation_size('query_results') as size from (select 1) as a"],
  +        ['Redash DB Size', "select pg_database_size('postgres') as size"]
  +    ]
  +    for query_name, query in queries:
  +        result = models.db.session.execute(query).first()
  +        database_metrics.append([query_name, result[0]])
  +
  +    return database_metrics
  +
  +
  +def get_status():
  +    status = {
  +        'version': __version__,
  +        'workers': []
  +    }
  +    status.update(get_redis_status())
  +    status.update(get_object_counts())
  +    status['manager'] = redis_connection.hgetall('redash:status')
  +    status['manager']['queues'] = get_queues_status()
  +    status['database_metrics'] = {}
  +    status['database_metrics']['metrics'] = get_db_sizes()
  +
       return status
  
verification_info: {"golden_diff": "diff --git a/redash/monitor.py b/redash/monitor.py\n--- a/redash/monitor.py\n+++ b/redash/monitor.py\n@@ -1,39 +1,72 @@\n from redash import redis_connection, models, __version__, settings\n \n \n-def get_status():\n-    status = {}\n+def get_redis_status():\n     info = redis_connection.info()\n-    status['redis_used_memory'] = info['used_memory']\n-    status['redis_used_memory_human'] = info['used_memory_human']\n-    status['version'] = __version__\n+    return {'redis_used_memory': info['used_memory'], 'redis_used_memory_human': info['used_memory_human']}\n+\n+\n+def get_object_counts():\n+    status = {}\n     status['queries_count'] = models.db.session.query(models.Query).count()\n     if settings.FEATURE_SHOW_QUERY_RESULTS_COUNT:\n         status['query_results_count'] = models.db.session.query(models.QueryResult).count()\n         status['unused_query_results_count'] = models.QueryResult.unused().count()\n     status['dashboards_count'] = models.Dashboard.query.count()\n     status['widgets_count'] = models.Widget.query.count()\n+    return status\n \n-    status['workers'] = []\n-\n-    status['manager'] = redis_connection.hgetall('redash:status')\n \n+def get_queues():\n     queues = {}\n     for ds in models.DataSource.query:\n         for queue in (ds.queue_name, ds.scheduled_queue_name):\n             queues.setdefault(queue, set())\n             queues[queue].add(ds.name)\n \n-    status['manager']['queues'] = {}\n+    return queues\n+\n+\n+def get_queues_status():\n+    queues = get_queues()\n+\n     for queue, sources in queues.iteritems():\n-        status['manager']['queues'][queue] = {\n+        queues[queue] = {\n             'data_sources': ', '.join(sources),\n             'size': redis_connection.llen(queue)\n         }\n     \n-    status['manager']['queues']['celery'] = {\n+    queues['celery'] = {\n         'size': redis_connection.llen('celery'),\n         'data_sources': ''\n     }\n \n+    return queues\n+\n+\n+def get_db_sizes():\n+    database_metrics = []\n+    queries = [\n+        ['Query Results Size', \"select pg_total_relation_size('query_results') as size from (select 1) as a\"],\n+        ['Redash DB Size', \"select pg_database_size('postgres') as size\"]\n+    ]\n+    for query_name, query in queries:\n+        result = models.db.session.execute(query).first()\n+        database_metrics.append([query_name, result[0]])\n+\n+    return database_metrics\n+\n+\n+def get_status():\n+    status = {\n+        'version': __version__,\n+        'workers': []\n+    }\n+    status.update(get_redis_status())\n+    status.update(get_object_counts())\n+    status['manager'] = redis_connection.hgetall('redash:status')\n+    status['manager']['queues'] = get_queues_status()\n+    status['database_metrics'] = {}\n+    status['database_metrics']['metrics'] = get_db_sizes()\n+\n     return status\n", "issue": "Add to status page the size of Redash's DB\n```sql\r\nSELECT pg_size_pretty(pg_total_relation_size('query_results'));\r\n```\r\n\r\n```sql\r\nSELECT pg_size_pretty(pg_database_size('redash'));\r\n```\n", "before_files": [{"content": "from redash import redis_connection, models, __version__, settings\n\n\ndef get_status():\n    status = {}\n    info = redis_connection.info()\n    status['redis_used_memory'] = info['used_memory']\n    status['redis_used_memory_human'] = info['used_memory_human']\n    status['version'] = __version__\n    status['queries_count'] = models.db.session.query(models.Query).count()\n    if settings.FEATURE_SHOW_QUERY_RESULTS_COUNT:\n        status['query_results_count'] = models.db.session.query(models.QueryResult).count()\n        status['unused_query_results_count'] = models.QueryResult.unused().count()\n    status['dashboards_count'] = models.Dashboard.query.count()\n    status['widgets_count'] = models.Widget.query.count()\n\n    status['workers'] = []\n\n    status['manager'] = redis_connection.hgetall('redash:status')\n\n    queues = {}\n    for ds in models.DataSource.query:\n        for queue in (ds.queue_name, ds.scheduled_queue_name):\n            queues.setdefault(queue, set())\n            queues[queue].add(ds.name)\n\n    status['manager']['queues'] = {}\n    for queue, sources in queues.iteritems():\n        status['manager']['queues'][queue] = {\n            'data_sources': ', '.join(sources),\n            'size': redis_connection.llen(queue)\n        }\n    \n    status['manager']['queues']['celery'] = {\n        'size': redis_connection.llen('celery'),\n        'data_sources': ''\n    }\n\n    return status\n", "path": "redash/monitor.py"}]}