Trac report #2 사용자별 최근변경사항

사용자별 최근 변경 사항 보는데 Trac report 만드는게 쉽지 않더군요. 더 쉬운 방법이 있는지 잘 모르겠지만… SQL 잘 하시는 분의 도움을 받아 만든 쿼리입니다. 저는 SQL을 잘게 짤라서 만드는 편인데, SQL 조금 복잡해지면 어렵고, 최적화도 어려워지죠.. 사용자 아이디와 출력되는 갯수가 하드코딩 되어야 해서 좀 그렇긴 하지만… 그래도 원하는대로 출력은 잘 해줍니다.

[code]
select
  p.value AS __color__,
  owner AS __group__,
  id AS ticket,
  (CASE status WHEN ‘assigned’ THEN owner||’ *’ ELSE owner END) AS owner,
  summary,
  component,
  priority,
  t.type AS type,
  status,
  time AS _created,
  changetime AS modified,
  description AS _description,
  reporter AS _reporter

from (

  select * from (SELECT * FROM ticket WHERE owner=’mix1009′ ORDER by changetime desc limit 0,5) u1

union

  select * from (SELECT * FROM ticket WHERE owner=’user2′ ORDER by changetime desc limit 0,5) u2

union

  select * from (SELECT * FROM ticket WHERE owner=’user3′ ORDER by changetime desc limit 0,5) u3

union

  select * from (SELECT * FROM ticket WHERE owner=’user4′ ORDER by changetime desc limit 0,5) u4

union

  select * from (SELECT * FROM ticket WHERE owner=’user5′ ORDER by changetime desc limit 0,5) u5

) t, enum p

where p.name = t.priority AND p.type = ‘priority’
order by owner, changetime desc
[/code]

One thought on “Trac report #2 사용자별 최근변경사항

  1. goodgene

    필요한 리포트였는데 좋은 정보 감사합니다 ^^.
    유저들을 하드 코딩하는 게 귀찮아서(!) 조금 손봐서 응용했습니다.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>