1

有许多创建TracReports的示例。仍然是一个棘手的问题,没有包含在任何现有的食谱中,我知道:

... 设计一个报告以显示用户是所有者、记者的所有工单,或他们尚未创建但他们留下评论的工单。这是最后一部分,这是棘手的。

任何指针,将有效性视为额外的奖励?

4

1 回答 1

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 专家,所以可能有一个更有效的解决方案,但这个解决方案至少可以显示评论的票证,而且每张票证不超过一次。

于 2012-08-29T23:26:51.760 回答