Edgewall Software
Modify

Opened 16 years ago

Closed 13 years ago

Last modified 13 years ago

#7821 closed defect (fixed)

grouping doesn't work in default_query

Reported by: m.galante@… Owned by: Jun Omae
Priority: normal Milestone: 0.12.3
Component: query system Version: 0.11.2
Severity: normal Keywords: USER
Cc: osimons Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Remy Blank)

I have set this in my "trac.ini":

[query]
default_query = status!=closed&group=milestone&owner=$USER

but when I click on the "View Tickets" button, the "Group results by" box is empty. This is from my "trac.log" file:

2008-11-14 18:45:16,326 Trac[main] DEBUG: Dispatching <Request "GET u'/query'">
2008-11-14 18:45:16,326 Trac[query] DEBUG: QueryModule: Using default query: status!=closed&group=milestone&owner=$USER
2008-11-14 18:45:16,326 Trac[chrome] DEBUG: Prepare chrome data for request
2008-11-14 18:45:16,342 Trac[session] DEBUG: Retrieving session for ID u'galante'
2008-11-14 18:45:16,342 Trac[query] DEBUG: Count results in Query: 131
2008-11-14 18:45:16,342 Trac[query] DEBUG: Query SQL: SELECT t.id AS id,t.summary AS summary,t.status AS status,t.type AS type,t.priority AS priority,t.milestone AS milestone,t.component AS component,t.time AS time,t.changetime AS changetime,t.owner AS owner,priority.value AS priority_value
FROM ticket AS t
  LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
WHERE COALESCE(t.status,'')!=u'closed' AND COALESCE(t.owner,'')=u'galante'
ORDER BY COALESCE(priority.value,'')='',CAST(priority.value AS int),t.id LIMIT 100 OFFSET 0
2008-11-14 18:45:16,358 Trac[perm] DEBUG: No policy allowed galante performing REPORT_VIEW on None
2008-11-14 18:45:16,983 Trac[perm] DEBUG: No policy allowed galante performing REPORT_CREATE on None
2008-11-14 18:45:17,187 Trac[main] DEBUG: 388 unreachable objects found.

I understand from #5998 that this should work on Trac 0.11.2, but it doesn't for me. I have tried with tracd on Windows and trac+apache on Linux, the client is Internet Explorer.

Attachments (1)

t7821-template-data-r10855.diff (2.1 KB ) - added by Jun Omae 13 years ago.

Download all attachments as: .zip

Change History (23)

in reply to:  description comment:1 by Remy Blank, 16 years ago

Description: modified (diff)
Resolution: worksforme
Status: newclosed

Replying to m.galante@…:

I understand from #5998 that this should work on Trac 0.11.2, but it doesn't for me.

#5998 allowed using the URL syntax for default_query, which is not quite the same as the query syntax. In your case, you should use the following:

[query]
default_query = ?status=!closed&group=milestone&owner=$USER

Note the leading ? and the modifier after the =.

I am trying to make both syntaxes converge in #7699, so this should get less confusing in the future.

comment:2 by Remy Blank, 16 years ago

Description: modified (diff)

Oops, changed the description inadvertently.

comment:3 by m.galante@…, 16 years ago

Using the URL syntax works, but I still see one problem. The Custom Query page shows the tickets filtered and grouped as requested, but the Owner field is empty. So if I click on the Update button I get no tickets found.

I think this is similar to the problem described in #7140.

comment:4 by Remy Blank, 16 years ago

So you're probably using restrict_owner = true. This problem will be fixed in #7258.

comment:5 by anonymous, 14 years ago

Resolution: worksforme
Status: closedreopened

It is happening to me on Trac 0.12.1. I tried various workarounds, like moving the group parameter inside the URL, but they did not help. It seems to affect only the grouping, but it prevents us from getting the optimal query be default.

(I'm also not sure that the "general" is the best component selection for this ticket.)

comment:6 by anonymous, 14 years ago

One more information on this: If I paste the URL of the right query into the browser, it can load the "group by" selector on the UI. So the problem might be in the code executed when the user clicks on the "View Tickets" link. That does not seem to be able to pass the group URL parameter in this case.

(Maybe it would be better to just navigate the URL with the query in it instead of trying to pass the whole thing internally, as it does, currently. Just an idea.)

comment:7 by anonymous, 14 years ago

For completeness, here is my query configuration from trac.ini:

[query]
default_anonymous_query = status!=closed&cc~=$USER
default_query = status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1
items_per_page = 100
ticketlink_query = status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1

comment:8 by anonymous, 14 years ago

I have restrict_owner set to true, but it should not affect the above behavior, I think.

comment:9 by Remy Blank, 14 years ago

Try using URL syntax (which is not the same as the query syntax, see comment:1):

[query]
default_anonymous_query = ?status=!closed&cc=~$USER
default_query = ?status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1
items_per_page = 100
ticketlink_query = ?status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1

comment:10 by Remy Blank, 14 years ago

Resolution: worksforme
Status: reopenedclosed

No reply, assuming URL syntax did the trick.

comment:11 by ruediger.kupper+trac@…, 13 years ago

Component: generalquery system
Resolution: worksforme
Status: closedreopened
Version: 0.11.20.12.2
  1. The original problem is still present in 0.12.2.
  2. It is not solved by using the URL syntax:

Using the URL syntax enables grouping okay, but the user field is then set to (litarally) "$User", i.e., the variable is not substituted.

Hence there is still no way of having the default query display all active tickets of the current user, grouped by status.

Strangely, doing the same thing for default_anonymous_query works okay:

This works
default_anonymous_query = status!=closed&cc~=$USER&group=status
This works not
default_query = ?status=!closed&owner=$USER&group=status

comment:12 by ruediger.kupper+trac@…, 13 years ago

Summary: group=milestone doesn't work in default_querygrouping doesn't work in default_query

comment:13 by Christian Boos, 13 years ago

Keywords: USER added
Milestone: next-minor-0.12.x

Thanks for the test case, we'll check this.

comment:14 by Jun Omae, 13 years ago

Owner: set to Jun Omae
Status: reopenednew

I'm working for the issue. The original issue is fixed in changeset:7824/jomae. The 2nd issue, $USER variable is still not substituted. query:owner=$USER has the same issue.

comment:15 by Jun Omae, 13 years ago

My work is finished in diff:jomae@7823:7825. The $USER variable is always substituted (e.g. default_query in trac.ini and query:owner=$USER).

comment:16 by Remy Blank, 13 years ago

Looks good.

comment:17 by Jun Omae, 13 years ago

Milestone: next-minor-0.12.x0.12.3
Resolution: fixed
Status: newclosed

The patch has been applied in [10852].

comment:18 by osimons, 13 years ago

Cc: osimons added
Resolution: fixed
Status: closedreopened

Sorry, but this change breaks as it seems that the query module passes a valid req whereas the [[TicketQuery]] passes None. Or something similar.

This on a wiki page:

[[TicketQuery(status=new|assigned|reopened,format=table)]]

Results in:

[] formatter.py:720 ERROR: Macro TicketQuery(status=new|assigned|reopened,format=table) failed: 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 717, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 304, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 291, in _macro_processor
    text)
  File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/ticket/query.py", line 1297, in expand_macro
    data = query.template_data(formatter.context, tickets)
  File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/ticket/query.py", line 707, in template_data
    val = val.replace('$USER', req.authname)
AttributeError: 'NoneType' object has no attribute 'authname'

by Jun Omae, 13 years ago

in reply to:  18 ; comment:19 by Jun Omae, 13 years ago

Replying to osimons:

Sorry, but this change breaks as it seems that the query module passes a valid req whereas the [[TicketQuery]] passes None. Or something similar.

Oops…. Sorry, I'm wrong.

Could you please try the patch, t7821-template-data-r10855.diff? All unit and functional tests pass in my environment.

in reply to:  19 comment:20 by osimons, 13 years ago

Replying to jomae:

Could you please try the patch, t7821-template-data-r10855.diff?

Looks & works correct. Thanks.

comment:21 by Jun Omae, 13 years ago

Resolution: fixed
Status: reopenedclosed

Thanks. Applied in [10861].

comment:22 by Stefan, 13 years ago

Version: 0.12.20.11.2

Issue had been present since 0.11.2 (not only since 0.12.2).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.