Edgewall Software

Opened 11 years ago

Last modified 10 years ago

#11288 closed defect

Incorrect title and link for batch-modify events in timeline rss — at Version 7

Reported by: Jun Omae Owned by: Jun Omae
Priority: low Milestone: 1.0.2
Component: ticket system Version: 1.0-stable
Severity: normal Keywords: batch-modify
Cc: Ryan J Ollos Branch:
Release Notes:

Fix duplicated ticket ids for batchmodify timeline events

API Changes:
Internal Changes:

Description

I've updated tickets using batch-modify feature at 2013-08-30T19:38:30+09:00. The title and link of the event are correct in timeline page. However, the title and link are incorrect in timeline rss. The ticket id are repeated in the title and link.

In timeline page:

  • title: Tickets #5499,​8813,​10740,​11219 batch updated by jomae
  • link: http://trac.edgewall.org/query?id=5499%2C8813%2C10740%2C11219

In timeline rss:

  • title: Tickets #5499,​8813,​10740,​10740,​11219,​11219 batch updated
  • link: http://trac.edgewall.org/query?id=5499%2C8813%2C10740%2C10740%2C11219%2C11219
    </item><item>
      <title>Tickets #5499,​8813,​10740,​10740,​11219,​11219 batch updated</title>
      
        <dc:creator>jomae</dc:creator>

      <pubDate>Fri, 30 Aug 2013 10:38:30 GMT</pubDate>
      <link>http://trac.edgewall.org/query?id=5499%2C8813%2C10740%2C10740%2C11219%2C11219</link>
      <guid isPermaLink="false">http://trac.edgewall.org/query?id=5499%2C8813%2C10740%2C10740%2C11219%2C11219/1377859110243015</guid>
      <description></description>
      <category>batchmodify</category>
    </item><item>

I don't know whether or not we can reproduce with 1.0-stable.

Change History (7)

comment:1 by Jun Omae, 11 years ago

Keywords: batch-modify added

comment:2 by Ryan J Ollos, 11 years ago

I've noticed this issue on t.e.o as well. Possibly related, my RSS reader (feedly) shows repeated entries for a batch modification change. Here is a recent example (timeline:2013-10-09T22:47):

There are more entries going back farther. Note that each RSS event has different duplicate tickets.

I haven't been able to reproduce the issue in a development environment. Looking at the code, it is rather strange that the timeline and RSS entries would be different, since each is generated by calling event.render:

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:3 by Jun Omae, 11 years ago

I suppose that the query in produce_ticket_change_events() should be the following at source:tags/trac-1.0.1/trac/ticket/web_ui.py@:294-299,305#L290.

  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    index e3f1ada..69f0e9f 100644
    a b class TicketModule(Component):  
    296296                    FROM ticket_change tc
    297297                        INNER JOIN ticket t ON t.id = tc.ticket
    298298                            AND tc.time>=%s AND tc.time<=%s
    299                     ORDER BY tc.time
     299                    ORDER BY tc.time, tc.ticket
    300300                    """ % (ts_start, ts_stop)):
    301301                if not (oldvalue or newvalue):
    302302                    # ignore empty change corresponding to custom field

The produce_ticket_change_events() iterates ticket.id and time for each ticketmodify. However, the query sorts only ticket_change.time. If the query returns the following, the same ticket id is returned more than once.

ticket      time              author      field       oldvalue    newvalue
----------  ----------------  ----------  ----------  ----------  ----------
3           1382348110040725  jun66j5     cc                      jun66j5
5           1382348110040725  jun66j5     cc                      jun66j5
6           1382348110040725  jun66j5     cc                      jun66j5
3           1382348110040725  jun66j5     comment     2
5           1382348110040725  jun66j5     comment     5
6           1382348110040725  jun66j5     comment     3

comment:4 by Peter Suter, 11 years ago

Interesting. Nice catch. I don't understand why only RSS is affected though.

comment:5 by Jun Omae, 11 years ago

Milestone: next-dev-1.1.x1.0.2
Version: 1.1.1dev1.0-stable

The issue depends on range for ticket_change.time and database backend. If the range is narrow, it rarely happens. Proposed fix and unit tests can be found in [1e458e62f/jomae.git].

If without the fix, TicketModule.get_timeline_events() for batch-modify returns duplicated ticket.id.

$ PYTHONPATH=. ~/venv/py25/bin/python trac/ticket/tests/batch.py
.........................F
======================================================================
FAIL: Regression test for #11288
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/ticket/tests/batch.py", line 301, in test_timeline_events
    self.assertEqual(ids, sorted(batch_ev[3][0]))
AssertionError: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20] != [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16,
16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20]

----------------------------------------------------------------------
Ran 26 tests in 1.553s

comment:6 by Peter Suter, 11 years ago

Ah, so it only occurs more often on RSS, because the default daysback parameter is larger there. But Timeline page can also trigger this (scroll down to August 30.) depending on daysback and from and bad luck / database backend.

Thanks for looking into this!

Last edited 11 years ago by Jun Omae (previous) (diff)

comment:7 by Jun Omae, 11 years ago

Owner: set to Jun Omae
Release Notes: modified (diff)
Status: newassigned
Note: See TracTickets for help on using tickets.