创建TracReports有很多例子。 This仍然是一个棘手的问题,我所知道的任何现有食谱都没有涵盖:
...设计报告以显示用户所在的所有门票 所有者,记者或他们没有创建的门票,但他们是门票 已发表评论。这是最后一个棘手的部分。
任何指针,考虑到有效性作为额外奖励?
答案 0 :(得分:0)
这是我的第一个自己的工作解决方案:
“(当前)用户是所有者或记者或(其中一位)评论作者”
SELECT
p.value AS __color__,
t.milestone AS __group__,
id AS ticket, t.type AS type,
reporter, t.time as created,
owner, changetime AS modified,
author as commenter, tcg.time as date
FROM ticket t
LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
LEFT JOIN ticket_change tcg ON t.id = tcg.ticket
WHERE owner = $USER OR reporter = $USER
GROUP BY id
UNION
SELECT
p.value AS __color__,
t.milestone AS __group__,
id AS ticket, t.type AS type,
reporter, t.time as created,
owner, changetime AS modified,
author as commenter, tcg.time as date
FROM ticket t
LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
LEFT JOIN ticket_change tcg ON t.id = tcg.ticket
WHERE author = $USER
AND id NOT IN (
SELECT id
FROM ticket
WHERE owner = $USER OR reporter = $USER
)
GROUP BY id
ORDER BY t.milestone, p.value, t.type, t.time
我绝不是SQL大师,所以可能会有一个更有效的解决方案,但是这个解决方案至少可以显示评论的票证,而且每张票证不会超过一次。