Edgewall Software
Modify

Opened 13 years ago

Last modified 4 years 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:
Internal 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, 13 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, 13 years ago

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

thanks Harel

comment:3 by Mitar, 13 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, 13 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, 13 years ago

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

SELECT id, description, filename, size
FROM attachment
WHERE type=="ticket"

or, to get direct links to the attachments:

SELECT 
 filename AS id, 'attachment' AS _realm,
 "ticket" AS _parent_realm, id AS _parent_id,
 description, size
FROM attachment
WHERE type=="ticket"
Last edited 13 years ago by Peter Suter (previous) (diff)

comment:6 by anonymous, 13 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 9 years ago by Ryan J Ollos (previous) (diff)

comment:7 by Peter Suter, 13 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, 13 years ago

Replying to psuter:

Something like this maybe: […]

It works! many thanks

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

comment:9 by Peter Suter, 9 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.
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.