#3655 closed defect (fixed)
Sample report to sort tickets by the number of votes
| Reported by: | anonymous | Owned by: | rjollos |
|---|---|---|---|
| Priority: | normal | Component: | VotePlugin |
| Severity: | normal | Keywords: | |
| Cc: | Trac Release: | 0.10 |
Description
Provide some sample SQL report which allows to sort the tickets according to the number of votes, also displaying the number of votes.
I don't know the database fields which are introduced by the voteplugin ...
Attachments (0)
Change History (9)
comment:1 Changed 5 years ago by andrew.vanpernis@…
comment:2 follow-up: ↓ 3 Changed 4 years ago by mauzer_tim
I'd vote for this ticket. BTW the SQL query above doesn't work. When I save it trac displays: ERROR: column "p.value" must appear in the GROUP BY clause or be used in an aggregate function
comment:3 in reply to: ↑ 2 Changed 4 years ago by avanpernis
Replying to mauzer_tim:
I'd vote for this ticket. BTW the SQL query above doesn't work. When I save it trac displays: ERROR: column "p.value" must appear in the GROUP BY clause or be used in an aggregate function
I wrote the query for
| Trac | 0.11.2.1 |
| Python | 2.5.2 |
| SQLite | 3.3.4 |
It works for me, so maybe it's a configuration difference.
comment:4 Changed 4 years ago by anonymous
Here's the query I used with PostgreSQL:
SELECT p.value AS __color__, id AS ticket, summary, component, version, milestone, t.type AS type, owner, status, votes, changetime AS _changetime, description AS _description, reporter AS _reporter FROM ticket t LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority' join (select resource, sum(vote) as votes from votes group by resource) as v ON (v.resource = 'ticket/'||t.id) WHERE status <> 'closed' ORDER BY votes DESC, p.value, time
comment:5 Changed 3 years ago by rjollos
- Owner changed from athomas to rjollos
Reassigning ticket to new maintainer.
comment:6 Changed 3 years ago by rjollos
- Summary changed from Provide sample report (SQL) to Sample report to sort tickets by the number of votes
This report exists on t.e.o: t:report:34
comment:7 Changed 3 years ago by rjollos
- Resolution set to fixed
- Status changed from new to closed
comment:8 Changed 3 years ago by rjollos
#4364 is a duplicate.
comment:9 Changed 5 weeks ago by hasienda
(In [13080]) VotePlugin: Update sample SQL reports following changes in [13079], refs #3655.


Here's a basic SQL query that should return all the tickets that have been voted on sorted by the total number of votes. I'm not a SQL expert, so perhaps this can be improved or simplified.