wiki:TracQuery

Trac Ticket Queries

In addition to reports, Trac provides support for custom ticket queries, used to display lists of tickets meeting a specified set of criteria.

To configure and execute a custom query, switch to the View Tickets module from the navigation bar, and select the Custom Query link.

Filters

When you first go to the query page the default filter will display tickets relevant to you:

  • If logged in then all open tickets it will display open tickets assigned to you.
  • If not logged in but you have specified a name or email address in the preferences then it will display all open tickets where your email (or name if email not defined) is in the CC list.
  • If not logged and no name/email defined in the preferences then all open issues are displayed.

Current filters can be removed by clicking the button to the left with the minus sign on the label. New filters are added from the pulldown lists at the bottom corners of the filters box ('And' conditions on the left, 'Or' conditions on the right). Filters with either a text box or a pulldown menu of options can be added multiple times to perform an or of the criteria.

You can use the fields just below the filters box to group the results based on a field, or display the full description for each ticket.

Once you've edited your filters click the Update button to refresh your results.

Clicking on one of the query results will take you to that ticket. You can navigate through the results by clicking the Next Ticket or Previous Ticket links just below the main menu bar, or click the Back to Query link to return to the query page.

You can safely edit any of the tickets and continue to navigate through the results using the Next/Previous/Back to Query links after saving your results. When you return to the query any tickets which were edited will be displayed with italicized text. If one of the tickets was edited such that it no longer matches the query criteria the text will also be greyed. Lastly, if a new ticket matching the query criteria has been created, it will be shown in bold.

The query results can be refreshed and cleared of these status indicators by clicking the Update button again.

Saving Queries

Trac allows you to save the query as a named query accessible from the reports module. To save a query ensure that you have Updated the view and then click the Save query button displayed beneath the results. You can also save references to queries in Wiki content, as described below.

Note: one way to easily build queries like the ones below, you can build and test the queries in the Custom report module and when ready - click Save query. This will build the query string for you. All you need to do is remove the extra line breaks.

Note: you must have the REPORT_CREATE permission in order to save queries to the list of default reports. The Save query button will only appear if you are logged in as a user that has been granted this permission. If your account does not have permission to create reports, you can still use the methods below to save a query.

You may want to save some queries so that you can come back to them later. You can do this by making a link to the query from any Wiki page.

[query:status=new|assigned|reopened&version=1.0 Active tickets against 1.0]

Which is displayed as:

Active tickets against 1.0

This uses a very simple query language to specify the criteria (see Query Language).

Alternatively, you can copy the query string of a query and paste that into the Wiki link, including the leading ? character:

[query:?status=new&status=assigned&status=reopened&group=owner Assigned tickets by owner]

Which is displayed as:

Assigned tickets by owner

Using the [[TicketQuery]] Macro

The TicketQuery macro lets you display lists of tickets matching certain criteria anywhere you can use WikiFormatting.

Example:

[[TicketQuery(version=0.6|0.7&resolution=duplicate)]]

This is displayed as:

No results

Just like the query: wiki links, the parameter of this macro expects a query string formatted according to the rules of the simple ticket query language. This also allows displaying the link and description of a single ticket:

[[TicketQuery(id=123)]]

This is displayed as:

No results

A more compact representation without the ticket summaries is also available:

[[TicketQuery(version=0.6|0.7&resolution=duplicate, compact)]]

This is displayed as:

No results

Finally, if you wish to receive only the number of defects that match the query, use the count parameter.

[[TicketQuery(version=0.6|0.7&resolution=duplicate, count)]]

This is displayed as:

0

Customizing the table format

You can also customize the columns displayed in the table format (format=table) by using col=<field> - you can specify multiple fields and what order they are displayed by placing pipes (|) between the columns like below:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter)]]

This is displayed as:

Results (1 - 3 of 13)

1 2 3 4 5
Ticket Resolution Summary Owner Reporter
#13 migrated CoinGetSolutionStatus is returning 0 when the solution is infeasible somebody sstewart
#12 migrated static compilation problem under Windows 32 bits somebody ycollet
#11 migrated CbcHeuristicDW not in VisualStudio solution somebody sstewart
1 2 3 4 5

Full rows

In table format you can also have full rows by using rows=<field> like below:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter,rows=description)]]

This is displayed as:

Results (1 - 3 of 13)

1 2 3 4 5
Ticket Resolution Summary Owner Reporter
#13 migrated CoinGetSolutionStatus is returning 0 when the solution is infeasible somebody sstewart
Description

If I watch the screen output CBC states that the problem is infeasible, but when I query CoinGetSolutionStatus? I get 0. To CoinMP this means Optimal Solution Found -- this is wrong. Here's the CoinMP code:

if (!pProblem->SolveAsMIP) {

pResult->SolutionStatus? = pCbc->clp->status(); pResult->ObjectValue? = pCbc->clp->objectiveValue(); pResult->MipBestBound? = 0.0; pResult->IterCount? = pCbc->clp->numberIterations(); pResult->MipNodeCount? = 0; }

else {

pResult->SolutionStatus? = pCbc->cbc->status(); pResult->ObjectValue? = pCbc->cbc->getObjValue(); pResult->MipBestBound? = pCbc->cbc->getBestPossibleObjValue(); pResult->IterCount? = pCbc->cbc->getIterationCount(); pResult->MipNodeCount? = pCbc->cbc->getNodeCount();

}

switch (pResult->SolutionStatus?) {

case 0: strcpy(pResult->SolutionText?, "Optimal solution found"); break; case 1: strcpy(pResult->SolutionText?, "Problem primal infeasible"); break; case 2: strcpy(pResult->SolutionText?, "Problem dual infeasible"); break; case 3: strcpy(pResult->SolutionText?, "Stopped on iterations"); break; case 4: strcpy(pResult->SolutionText?, "Stopped due to errors"); break; case 5: strcpy(pResult->SolutionText?, "Stopped by user"); break;

But here is the info from the CBC user guide on Status (https://www.coin-or.org/Cbc/cbcuserguide.html#gettingsolution):

Optimality can be checked through a call to model.isProvenOptimal(). Also available are isProvenInfeasible(), isSolutionLimitReached(), isNodeLimitReached() or the feared isAbandoned(). There is also int status() which returns 0 if finished (which includes the case when the algorithm is finished because it has been proved infeasible), 1 if stopped by user, and 2 if difficulties arose.

So the code might be right for linear but it's wrong for integer...

Wrong in 1.8.3 and trunk as far as I can tell.

Here's the screen output Starting File Directory:C:\MPS\ Print Matrix: True Run Solver: True Coin problem -- error code: -1 Writing matrix to disk MPS file written to C:\MPS\Solver4.mps Welcome to the CBC MILP Solver Version: 2.8 Build Date: Jan 7 2014

command line - CoinMP -solve -quit (default strategy 1) Continuous objective value is -3.20289 - 0.00 seconds Cgl0000I Cut generators found to be infeasible! (or unbounded) Pre-processing says infeasible or unbounded Total time (CPU seconds): 0.00 (Wallclock seconds): 0.00

and here's the MPS

NAME BLANK ROWS

N OBJROW L R0 L R1 L R2 L R3 L R4 L R5 L R6 L R7 L R8 L R9 L R10 L R11 L R12 L R13 L R14 L R15 L R16 L R17 L R18 L R19 L R20 L R21 L R22 L R23 L R24 L R25 L R26 G R27 G R28 G R29 G R30 G R31 G R32 G R33 G R34 G R35 G R36 G R37 G R38 G R39 G R40 G R41 G R42 E R43 E R44 L R45 L R46 L R47 L R48 L R49 L R50 L R51 G R52 G R53 G R54 L R55 L R56 L R57 L R58 G R59 G R60 G R61

COLUMNS

C0 OBJROW -1.2028861 R16 1.202886102 C0 R22 1. R24 3.501 C0 R25 3.501 R26 3.501 C0 R29 1. R30 1. C0 R43 1. R45 3501. C0 R51 3501. R53 3501. C0 R58 3501. R60 3501. C1 OBJROW -1.2028861 R17 1.202886102 C1 R22 1. R25 3.501 C1 R26 3.501 R30 1. C1 R48 3501. R58 3501. C1 R60 3501. C2 OBJROW -1.2028861 R18 1.202886102 C2 R22 1. R26 3.501 C2 R55 3501. C3 OBJROW -0.7971139 R16 0.797113898 C3 R23 1. R24 2.32 C3 R25 2.32 R26 2.32 C3 R33 1. R34 1. C3 R45 2320. R51 2320. C3 R53 2320. R58 2320. C3 R60 2320. C4 OBJROW -0.7971139 R17 0.797113898 C4 R23 1. R25 2.32 C4 R26 2.32 R34 1. C4 R48 2320. R58 2320. C4 R60 2320. C5 OBJROW -0.7971139 R18 0.797113898 C5 R23 1. R26 2.32 C5 R44 1. R55 2320. C6 OBJROW -1.2028861 R16 1.202886102 C6 R24 -3.501 R25 -3.501 C6 R26 -3.501 R28 -1. C6 R29 -1. R30 -1. C6 R37 1. R38 1. C6 R46 3501. R51 -3501. C6 R53 -3501. R58 -3501. C6 R60 -3501. C7 OBJROW -1.2028861 R17 1.202886102 C7 R25 -3.501 R26 -3.501 C7 R29 -1. R30 -1. C7 R38 1. R49 3501. C7 R58 -3501. R60 -3501. C8 OBJROW -1.2028861 R18 1.202886102 C8 R26 -3.501 R30 -1. C8 R56 3501. C9 OBJROW -0.7971139 R16 0.797113898 C9 R24 -2.32 R25 -2.32 C9 R26 -2.32 R32 -1. C9 R33 -1. R34 -1. C9 R41 1. R42 1. C9 R46 2320. R51 -2320. C9 R53 -2320. R58 -2320. C9 R60 -2320. C10 OBJROW -0.7971139 R17 0.797113898 C10 R25 -2.32 R26 -2.32 C10 R33 -1. R34 -1. C10 R42 1. R49 2320. C10 R58 -2320. R60 -2320. C11 OBJROW -0.7971139 R18 0.797113898 C11 R26 -2.32 R34 -1. C11 R56 2320. C12 OBJROW -1.2028861 R19 1.202886102 C12 R24 -3.501 R25 -3.501 C12 R26 -3.501 R28 -1. C12 R29 -1. R30 -1. C12 R37 1. R38 1. C12 R46 3501. R51 -3501. C12 R53 -3501. R58 -3501. C12 R60 -3501. C13 OBJROW -1.2028861 R20 1.202886102 C13 R25 -3.501 R26 -3.501 C13 R29 -1. R30 -1. C13 R38 1. R49 3501. C13 R58 -3501. R60 -3501. C14 OBJROW -1.2028861 R21 1.202886102 C14 R26 -3.501 R30 -1. C14 R56 3501. C15 OBJROW -0.7971139 R19 0.797113898 C15 R24 -2.32 R25 -2.32 C15 R26 -2.32 R32 -1. C15 R33 -1. R34 -1. C15 R41 1. R42 1. C15 R46 2320. R51 -2320. C15 R53 -2320. R58 -2320. C15 R60 -2320. C16 OBJROW -0.7971139 R20 0.797113898 C16 R25 -2.32 R26 -2.32 C16 R33 -1. R34 -1. C16 R42 1. R49 2320. C16 R58 -2320. R60 -2320. C17 OBJROW -0.7971139 R21 0.797113898 C17 R26 -2.32 R34 -1. C17 R56 2320. C42 R45 -5000. R47 1. C42 R52 1. C43 R46 -5000. R47 1. C43 R54 1. C44 R48 -5000. R50 1. C44 R52 -1. R59 1. C45 R49 -5000. R50 1. C45 R54 -1. R61 1. C46 R51 4500. R52 1. C47 R53 -4500. R54 1. C48 R55 -5000. R57 1. C48 R59 -1. C49 R56 -5000. R57 1. C49 R61 -1. C50 R58 4500. R59 1. C51 R60 -4500. R61 1.

RHS

RHS R0 1367. R1 1367. RHS R2 2941. R3 2941. RHS R4 766.7 R5 766.7 RHS R6 32.9 R7 32.9 RHS R8 1333.3 R9 1333.3 RHS R10 833.3 R11 833.3 RHS R12 8.22 R13 8.22 RHS R14 3992.3 R15 3992.3 RHS R16 3.2393409792 R17 3.2393409792 RHS R18 3.2393409792 R19 0.8359589624 RHS R20 0.8359589624 R21 0.8359589624 RHS R22 1. R23 1. RHS R24 5. R25 5. RHS R26 5. R43 1. RHS R44 1. R47 1. RHS R50 1. R51 5000. RHS R57 1. R58 5000.

BOUNDS

UP BOUND C0 1. UP BOUND C1 1. UP BOUND C2 1. UP BOUND C3 1. UP BOUND C4 1. UP BOUND C5 1. UP BOUND C6 1. UP BOUND C7 1. UP BOUND C8 1. UP BOUND C9 1. UP BOUND C10 1. UP BOUND C11 1. UP BOUND C12 1. UP BOUND C13 1. UP BOUND C14 1. UP BOUND C15 1. UP BOUND C16 1. UP BOUND C17 1. BV BOUND C42 1. BV BOUND C43 1. BV BOUND C44 1. BV BOUND C45 1. BV BOUND C46 1. BV BOUND C47 1. BV BOUND C48 1. BV BOUND C49 1. BV BOUND C50 1. BV BOUND C51 1.

ENDATA

#12 migrated static compilation problem under Windows 32 bits somebody ycollet
Description

When I try to compile CoinMP on Windows in 32 bits, I am not able to link my example with the library. The linker complains about missing sympbols. I tracked down the problem. It comes from CoinMP.h:

#if defined(_MSC_VER) && !defined(HAVE_CONFIG_H)

# define SOLVCALL   __stdcall
# if defined(SOLVER_EXPORT) && !defined(_WIN64)
#  define SOLVAPI  __declspec(dllexport)
# endif
# if defined(SOLVER_IMPORT)
#  define SOLVAPI __declspec(dllimport)
# endif

If I remove "# define SOLVCALL stdcall" and " && !defined(_WIN64)" everything is working fine.

#11 migrated CbcHeuristicDW not in VisualStudio solution somebody sstewart
Description

Hi -- I upgraded the /MSVisualStudio/v9 CoinMP.sln file to VS2015, and it built in debug but not release (64 bit). Had to add CBCHeuristicDW.cpp to libCbc\Source Files in solution explorer and then everything was fine.

1 2 3 4 5

Query Language

query: TracLinks and the [[TicketQuery]] macro both use a mini “query language” for specifying query filters. Basically, the filters are separated by ampersands (&). Each filter then consists of the ticket field name, an operator, and one or more values. More than one value are separated by a pipe (|), meaning that the filter matches any of the values. To include a literal & or | in a value, escape the character with a backslash (\).

The available operators are:

= the field content exactly matches one of the values
~= the field content contains one or more of the values
^= the field content starts with one of the values
$= the field content ends with one of the values

All of these operators can also be negated:

!= the field content matches none of the values
!~= the field content does not contain any of the values
!^= the field content does not start with any of the values
!$= the field content does not end with any of the values

The date fields created and modified can be constrained by using the = operator and specifying a value containing two dates separated by two dots (..). Either end of the date range can be left empty, meaning that the corresponding end of the range is open. The date parser understands a few natural date specifications like "3 weeks ago", "last month" and "now", as well as Bugzilla-style date specifications like "1d", "2w", "3m" or "4y" for 1 day, 2 weeks, 3 months and 4 years, respectively. Spaces in date specifications can be left out to avoid having to quote the query string.

created=2007-01-01..2008-01-01 query tickets created in 2007
created=lastmonth..thismonth query tickets created during the previous month
modified=1weekago.. query tickets that have been modified in the last week
modified=..30daysago query tickets that have been inactive for the last 30 days

See also: TracTickets, TracReports, TracGuide

Last modified 6 years ago Last modified on Aug 20, 2013 9:17:22 PM