Edgewall Software
Modify

Opened 9 years ago

Last modified 7 months ago

#10286 new enhancement

Way to query all tickets with attachments

Reported by: Mitar Owned by:
Priority: normal Milestone: next-major-releases
Component: query system Version: 0.12.1
Severity: normal Keywords:
Cc: mmitar@… Branch:
Release Notes:
API Changes:

Description

Trac should provide a way to query all tickets with attachments, or even better, with a given name/description in an attachment. Or maybe even attachment size(s) (individual or combined).

Attachments (0)

Change History (9)

comment:1 by Remy Blank, 9 years ago

Milestone: next-major-0.1X

Sounds like a good addition to the ticket query system. Note that you can probably already do that with reports.

comment:2 by anonymous, 8 years ago

How do you do it with reports? will you give an example please?

thanks Harel

comment:3 by Mitar, 8 years ago

You write an SQL query. ;-)

Reports = old system, using SQL queries. Query system = new inteface, generating SQL queries internally.

comment:4 by anonymous, 8 years ago

As far as I see, The attachments are not stored inside the DB, but in a separated directory. Therefore, I don;t know How to write such query / report. Whould you please give ne an example?

Thanks Harel

comment:5 by Peter Suter, 8 years ago

The attachments themselves are not stored in the DB, but there is some metadata.

SELECT id, description, filename, size
FROM attachment
WHERE type=="ticket"
Version 0, edited 8 years ago by Peter Suter (next)

comment:6 by anonymous, 8 years ago

thanks, It works! If I may, another question: The query above displays each attachment as a separated result. How can I make it displaying by tickets, i.e. display all files that are related to the same ticket as one result (one row in the results table) Thanks again Harel

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

comment:7 by Peter Suter, 8 years ago

Something like this maybe:

SELECT t.id as id,
       t.summary as summary,
       group_concat(a.description,", ") as "file descriptions",
       group_concat(a.filename,", ") as files
FROM attachment a
INNER JOIN ticket t
ON a.id == t.id
WHERE a.type=="ticket"
GROUP BY t.id

Or to get one table per ticket with one row per attachment:

SELECT a.filename AS id, "attachment" AS _realm,
       "ticket" AS _parent_realm, t.id AS _parent_id,
       a.description as description,
       a.size as size,
       "#" || t.id || " " || t.summary as  __group__,
       '../ticket/' || t.id as __grouplink__
FROM attachment a
INNER JOIN ticket t
ON a.id == t.id
WHERE a.type=="ticket"

in reply to:  7 comment:8 by anonymous, 8 years ago

Replying to psuter:

Something like this maybe: […]

It works! many thanks

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

comment:9 by Peter Suter, 5 years ago

Possibly this could be provided after #10983.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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