Changeset 3023

Show
Ignore:
Timestamp:
01/10/08 19:01:15 (1 year ago)
Author:
athomas
Message:

Added [tags].ignore_closed_tickets option which will skip collecting tags
from closed tickets if enabled.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tagsplugin/trunk/tractags/ticket.py

    r2954 r3023  
    1313from trac.util.text import to_unicode 
    1414from trac.util.compat import set, sorted 
    15 from trac.config import ListOption 
     15from trac.config import * 
    1616from trac.resource import Resource 
    1717 
     
    2626    fields = ListOption('tags', 'ticket_fields', 'keywords', 
    2727        doc='List of ticket fields to expose as tags.') 
     28 
     29    ignore_closed_tickets = BoolOption('tags', 'ignore_closed_tickets', True, 
     30        'Do not collect tags from closed tickets.') 
    2831 
    2932#    custom_fields = ListOption('tags', 'custom_ticket_fields', 
     
    4245        cursor = db.cursor() 
    4346        args = [] 
    44         sql = "SELECT * FROM (SELECT id, %s, %s AS fields FROM ticket) s" % (','.join(self.fields), 
    45             '||'.join(["COALESCE(%s, '')" % f for f in self.fields])) 
     47        fields = self.fields 
     48        ignore = '' 
     49        if self.ignore_closed_tickets: 
     50            ignore = " WHERE status != 'closed'" 
     51        sql = "SELECT * FROM (SELECT id, %s, %s AS fields FROM ticket%s) s" % ( 
     52            ','.join(self.fields), 
     53            '||'.join(["COALESCE(%s, '')" % f for f in self.fields]), 
     54            ignore) 
    4655        constraints = [] 
    4756        if tags: 
     
    5564            sql += " WHERE " + " AND ".join(constraints) 
    5665        sql += " ORDER BY id" 
     66        self.env.log.debug(sql) 
    5767        cursor.execute(sql, args) 
    5868        for row in cursor: