Changeset e25994e in osmose-frontend


Ignore:
Timestamp:
Nov 5, 2012 10:27:57 PM (5 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
6ee292d
Parents:
6a4c0e0
git-author:
Frédéric Rodrigo <frodrigo@…> (02/11/2012 18:44:10)
git-committer:
Frédéric Rodrigo <frodrigo@…> (05/11/2012 22:27:57)
Message:

Display update median delay on map page

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • map.py

    rce387de re25994e  
    9494    allowed_languages = utils.allowed_languages 
    9595 
     96    sql = """ 
     97SELECT 
     98    age 
     99FROM 
     100    ( 
     101    SELECT DISTINCT ON (source) 
     102        source, 
     103        EXTRACT(EPOCH FROM ((now())-timestamp)) AS age 
     104    FROM 
     105        dynpoi_update 
     106    ORDER BY 
     107        source ASC, 
     108        timestamp DESC 
     109    ) AS delay 
     110ORDER BY 
     111    age 
     112LIMIT 
     113    1 OFFSET (SELECT COUNT(*)/2 FROM 
     114    ( 
     115    SELECT DISTINCT ON (source) 
     116        source, 
     117        EXTRACT(EPOCH FROM ((now())-timestamp)) AS age 
     118    FROM 
     119        dynpoi_update 
     120    ORDER BY 
     121        source ASC, 
     122        timestamp DESC 
     123    ) AS delay 
     124) 
     125; 
     126""" 
     127    db.execute(sql) 
     128    delay = db.fetchone() 
     129    if delay: 
     130        delay = delay[0]/60/60/24 
     131 
    96132    return template('map/index', categories=categories, lat=lat, lon=lon, zoom=zoom, source=source, user=user, 
    97         levels=levels, level_selected=level_selected, active_items=active_items, urls=urls, allowed_languages=allowed_languages, translate=utils.translator(lang)) 
     133        levels=levels, level_selected=level_selected, active_items=active_items, urls=urls, delay=delay, 
     134        allowed_languages=allowed_languages, translate=utils.translator(lang)) 
    98135 
    99136 
  • static/map/style.css

    r3274bb2 re25994e  
    353353  font-size: 11px; 
    354354} 
     355 
     356.delay-normal { 
     357    background: green; 
     358} 
     359.delay-warning { 
     360    background: orange; 
     361} 
     362.delay-error { 
     363    background: red; 
     364} 
  • views/map/index.tpl

    r6e7d36d re25994e  
    115115 &mdash; <a href='{{u[1]}}'>{{u[0]}}</a> 
    116116%end 
     117 
     118%delay_status = "normal" if delay < 1.1 else "warning" if delay < 1.6 else "error" 
     119%delay = "%0.2f" % delay 
     120<span class="delay-{{delay_status}}">{{_("Delay: %sd") % delay}}</span> 
    117121</div> 
    118122 
Note: See TracChangeset for help on using the changeset viewer.