Changeset 6ee292d in osmose-frontend


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

Simplify control list updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • control.py

    rdc7e2b1 r6ee292d  
    3030def updates(db): 
    3131    db.execute(""" 
    32 SELECT DISTINCT ON (source) 
    33     source, 
    34     EXTRACT(EPOCH FROM ((now())-timestamp)) AS age, 
    35     remote_url, 
    36     remote_ip 
     32SELECT DISTINCT ON (dynpoi_source.source) 
     33    dynpoi_source.source, 
     34    EXTRACT(EPOCH FROM ((now())-dynpoi_update.timestamp)) AS age, 
     35    dynpoi_source.comment 
    3736FROM 
    38     dynpoi_update 
     37    dynpoi_source 
     38    LEFT JOIN dynpoi_update ON 
     39        dynpoi_source.source = dynpoi_update.source 
    3940ORDER BY 
    40     source ASC, 
    41     timestamp DESC 
     41    dynpoi_source.source ASC, 
     42    dynpoi_update.timestamp DESC 
    4243""") 
    43     lasts = {} 
     44    liste = [] 
    4445    for res in db.fetchall(): 
    45         lasts[int(res["source"])] = res 
    46  
    47     sources = utils.get_sources() 
    48  
    49     liste = [] 
    50     for source_id in [str(y) for y in sorted([int(x) for x in sources])]: 
    51         like = sources[source_id].get("like", source_id) 
    52         if int(source_id) in lasts: 
    53             age  = lasts[int(source_id)]["age"] 
     46        source, age, comment = res 
     47        if age: 
    5448            if age >= 0: 
    5549                # TRANSLATORS: days / hours / minutes since last source update, abbreviated to d / h / m 
     
    5751            else: 
    5852                txt = _("in {day}d, {hour}h, {minute}m").format(day=int(-age/86400), hour=int(-age/3600)%24, minute=int(-age/60)%60) 
    59             liste.append((sources[source_id]["comment"], age, txt, source_id)) 
     53            liste.append((comment, age, txt, source)) 
    6054        else: 
    61             liste.append((sources[source_id]["comment"], 1e10, _("never generated"), source_id)) 
     55            liste.append((comment, 1e10, _("never generated"), source)) 
    6256    liste.sort(lambda x, y: -cmp(x[1], y[1])) 
    6357 
Note: See TracChangeset for help on using the changeset viewer.