Edgewall Software

Opened 4 years ago

Last modified 3 years ago

#12414 new enhancement

Improve API for getting comment number — at Version 1

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: ticket system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description (last modified by Jun Omae)

E.g. in ITicketManipulator.validate_ticket it is surprisingly difficult to get the comment number of the comment to be validated.

ticket.get_comment_number(ticket['changetime']) often gives the previous comment number, but fails e.g. when the a comment was edited. (th:#12714)

Am I missing something or could the API be improved somehow? Thanks.

Change History (1)

comment:1 by Jun Omae, 4 years ago

Component: generalticket system
Description: modified (diff)

You could use TicketModule.grouped_changelog_entries().

    def _get_ticket_cnum(self, ticket, modtime):
        for change in TicketModule(self.env) \
                      .grouped_changelog_entries(ticket, when=modtime):
            return change['cnum']

See tags/trac-1.0.10/trac/ticket/notification.py@:181-182,191#L165.

Note: See TracTickets for help on using tickets.