stable
Clone or download
This is a part of story #8858: query tracker with expressions If user enters a simple query (e.g: status = "On going") then the matching artifacts are displayed. TQL --- This introduces TQL (Tuleap Query Language) If you need to modify the grammar, you go to plugins/tracker/grammar and follow the white rabbit in Readme.mkd Technical notes --------------- About searching in the database: As of today, to search in trackers, the generated query looks like the following: If we search all artifacts containing 'Toto' in the field `epic`: SELECT c.artifact_id AS id, c.id AS last_changeset_id FROM tracker_artifact AS artifact INNER JOIN tracker_changeset AS c ON (artifact.last_changeset_id = c.id) INNER JOIN tracker_changeset_value AS A_521 ON (A_521.changeset_id = c.id AND A_521.field_id = 521 ) INNER JOIN tracker_changeset_value_text AS B_521 ON (B_521.changeset_value_id = A_521.id AND B_521.value LIKE '%Toto%' ) WHERE artifact.tracker_id = 17; If we search all artifacts with `progress` field set to 'To do' SELECT c.artifact_id AS id, c.id AS last_changeset_id FROM tracker_artifact AS artifact INNER JOIN tracker_changeset AS c ON (artifact.last_changeset_id = c.id) INNER JOIN tracker_changeset_value AS A_523 ON (A_523.changeset_id = c.id AND A_523.field_id IN (523)) INNER JOIN tracker_changeset_value_list AS C_523 ON ( C_523.changeset_value_id = A_523.id AND C_523.bindvalue_id IN(456) ) WHERE artifact.tracker_id = 17; If we combine both criteria (Epic = Toto && Progress = To do) SELECT c.artifact_id AS id, c.id AS last_changeset_id FROM tracker_artifact AS artifact INNER JOIN tracker_changeset AS c ON (artifact.last_changeset_id = c.id) INNER JOIN tracker_changeset_value AS A_521 ON (A_521.changeset_id = c.id AND A_521.field_id = 521 ) INNER JOIN tracker_changeset_value_text AS B_521 ON (B_521.changeset_value_id = A_521.id AND B_521.value LIKE '%Toto%' ) INNER JOIN tracker_changeset_value AS A_523 ON (A_523.changeset_id = c.id AND A_523.field_id IN (523)) INNER JOIN tracker_changeset_value_list AS C_523 ON ( C_523.changeset_value_id = A_523.id AND C_523.bindvalue_id IN(456) ) WHERE artifact.tracker_id = 17; If we want to be able to search with OR, for example the following query: (Epic = Toto || Epic = Titi) && Progress = To do, then we must convert some INNER JOIN to LEFT JOIN and combine them with AND/OR in the where clause: SELECT c.artifact_id AS id, c.id AS last_changeset_id FROM tracker_artifact AS artifact INNER JOIN tracker_changeset AS c ON (artifact.last_changeset_id = c.id) LEFT JOIN ( tracker_changeset_value AS A_521 INNER JOIN tracker_changeset_value_text AS B_521 ON (B_521.changeset_value_id = A_521.id AND B_521.value LIKE '%Toto%' ) ) ON (A_521.changeset_id = c.id AND A_521.field_id = 521 ) LEFT JOIN ( tracker_changeset_value AS A_521_2 INNER JOIN tracker_changeset_value_text AS B_521_2 ON (B_521_2.changeset_value_id = A_521_2.id AND B_521_2.value LIKE '%Titi%' ) ) ON (A_521_2.changeset_id = c.id AND A_521_2.field_id = 521 ) LEFT JOIN ( tracker_changeset_value AS A_523 INNER JOIN tracker_changeset_value_list AS C_523 ON ( C_523.changeset_value_id = A_523.id AND C_523.bindvalue_id IN(456) ) ) ON (A_523.changeset_id = c.id AND A_523.field_id IN (523)) WHERE artifact.tracker_id = 17 AND (A_523.changeset_id IS NOT NULL AND (A_521.changeset_id IS NOT NULL OR A_521_2.changeset_id IS NOT NULL) ); Please note that a field may appear more than once in the advanced query, this explain the A_521, A_521_2, … Change-Id: I68afe94b1d07dd2958721f67c8be4f31c981b36d
Modified Files
Name | ||||
---|---|---|---|---|
M | gulpfile.js | +16 | −3 | Go to diff View file |
A | plugins/tracker/grammar/Readme.mkd | +21 | −0 | Go to diff View file |
A | plugins/tracker/grammar/generate_parser.js | +36 | −0 | Go to diff View file |
A | plugins/tracker/grammar/package.json | +9 | −0 | Go to diff View file |
A | plugins/tracker/grammar/test_parser.php | +41 | −0 | Go to diff View file |
A | plugins/tracker/grammar/tql.pegjs | +142 | −0 | Go to diff View file |
M | plugins/tracker/include/Tracker/FormElement/Tracker_FormElement_Field_Text.class.php | +14 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/.gitignore | +1 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/AndExpression.php | +51 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/AndOperand.php | +38 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/Comparison.php | +55 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/FieldDoesNotExistException.php | +27 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/FieldIsNotSupported.php | +27 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/OrExpression.php | +51 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/OrOperand.php | +38 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/Term.php | +24 | −0 | Go to diff View file |
A | plugins/tracker/include/Tracker/Report/Query/Advanced/Grammar/Validator.php | +55 | −0 | Go to diff View file |
M | plugins/tracker/include/Tracker/Report/Tracker_Report.class.php | +173 | −62 | Go to diff View file |
M | plugins/tracker/include/autoload.php | +11 | −2 | Go to diff View file |
A | plugins/tracker/include/manual_autoload.php | +28 | −0 | Go to diff View file |
M | plugins/tracker/include/trackerPlugin.class.php | +1 | −0 | Go to diff View file |
M | plugins/tracker/site-content/en_US/tracker.tab | +4 | −1 | Go to diff View file |
M | plugins/tracker/site-content/fr_FR/tracker.tab | +4 | −1 | Go to diff View file |
A | plugins/tracker/tests/Tracker/Report/Query/Advanced/Grammar/OrExpressionTest.php | +44 | −0 | Go to diff View file |
A | plugins/tracker/tests/Tracker/Report/Query/Advanced/Grammar/ParserTest.php | +66 | −0 | Go to diff View file |
A | plugins/tracker/tests/Tracker/Report/Query/Advanced/Grammar/ValidatorTest.php | +66 | −0 | Go to diff View file |
M | plugins/tracker/tests/bootstrap.php | +2 | −3 | Go to diff View file |