Edgewall Software

Ticket #9282: t9282-timeline-lastread-in-microseconds.patch

File t9282-timeline-lastread-in-microseconds.patch, 2.8 KB (added by cboos, 2 years ago)

#9282: use microsecond timestamps for storing and comparing lastread (applies on previous patch)

  • trac/timeline/templates/timeline.html

    From b1b47325d7426599dc6f4767f26b1726b8edd81b Mon Sep 17 00:00:00 2001
    From: Christian Boos <cboos@neuf.fr>
    Date: Fri, 30 Apr 2010 22:55:20 +0200
    Subject: [PATCH] #9282: use microsecond timestamps for storing and comparing lastread.
    
    ---
     trac/timeline/templates/timeline.html |    9 ++++-----
     trac/timeline/web_ui.py               |    4 ++--
     2 files changed, 6 insertions(+), 7 deletions(-)
    
    diff --git a/trac/timeline/templates/timeline.html b/trac/timeline/templates/timeline.html
    index 77556fd..292ae36 100644
    a b  
    3232       </div> 
    3333      </form> 
    3434 
    35       <py:for each="day, events in groupby(events, key=lambda e: format_date(e.date))"> 
     35      <py:for each="day, events in groupby(events, key=lambda e: format_date(e.date))" 
     36              py:with="highlight = precision and precisedate and timedelta(0) &lt;= (event.date - precisedate) &lt; precision"> 
    3637        <h2>${day}: ${day == today and _("Today") or day == yesterday and _("Yesterday") or None}</h2> 
    37         <dl py:for="unread, events in groupby(events, key= 
    38                 lambda e: lastread and lastread &lt; e.date.isoformat())" 
     38        <dl py:for="unread, events in groupby(events, key=lambda e: lastread and lastread &lt; e.dateuid)" 
    3939            class="${unread and 'unread' or None}"> 
    40           <py:for each="event in events" 
    41             py:with="highlight = precision and precisedate and timedelta(0) &lt;= (event.date - precisedate) &lt; precision"> 
     40          <py:for each="event in events"> 
    4241            <dt class="${classes(event.kind, highlight=highlight, unread=unread)}"> 
    4342              <a href="${event.render('url', context)}" py:choose=""> 
    4443                <py:when test="event.author"><i18n:msg params="time, title, author"> 
  • trac/timeline/web_ui.py

    diff --git a/trac/timeline/web_ui.py b/trac/timeline/web_ui.py
    index a8ce4eb..da559c2 100644
    a b class TimelineModule(Component): 
    8989 
    9090        format = req.args.get('format') 
    9191        maxrows = int(req.args.get('max', 0)) 
    92         lastread = req.session.get('timeline.lastread', '') 
     92        lastread = int(req.session.get('timeline.lastread', '0')) 
    9393 
    9494        # Parse the from date and adjust the timestamp to the last second of 
    9595        # the day 
    class TimelineModule(Component): 
    208208            req.session['timeline.authors'] = authors 
    209209            # store lastread 
    210210            if events: 
    211                 lastviewed = events[0]['date'].isoformat() 
     211                lastviewed = to_utimestamp(events[0]['date']) 
    212212                req.session['timeline.lastread'] = max(lastread, lastviewed) 
    213213            html_context = Context.from_request(req) 
    214214            html_context.set_hints(wiki_flavor='oneliner',