Ticket #3655 (closed defect: fixed)

Opened 3 years ago

Last modified 1 year ago

Sample report to sort tickets by the number of votes

Reported by: anonymous Assigned to: 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

Change History

09/10/08 01:56:37 changed by andrew.vanpernis@in-three.com

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.

SELECT  p.value AS __color__,
   id AS ticket, summary, component, version, milestone, t.type AS type, 
   owner, status,
   SUM (v.vote) AS 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'
  LEFT OUTER JOIN votes v ON (v.resource = 'ticket/'||t.id)
  WHERE status <> 'closed' AND v.vote IS NOT NULL
  GROUP BY id 
  ORDER BY votes DESC, p.value, time

(follow-up: ↓ 3 ) 01/15/09 03:10:43 changed 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

(in reply to: ↑ 2 ) 01/15/09 13:44:07 changed 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

Trac0.11.2.1
Python2.5.2
SQLite3.3.4

It works for me, so maybe it's a configuration difference.

05/08/09 00:59:13 changed 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

08/27/10 21:36:51 changed by rjollos

  • owner changed from athomas to rjollos.

Reassigning ticket to new maintainer.

08/27/10 23:33:02 changed 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

08/28/10 00:06:25 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

(In [8473]) Added SQL query for a report that sorts tickets by the number of votes. SQL is taken from the t.e.o. site. Fixes #3655.

08/28/10 00:08:16 changed by rjollos

#4364 is a duplicate.


Add/Change #3655 (Sample report to sort tickets by the number of votes)




Change Properties
Action