如何在 Trac 中创建在特定日期关闭的票证报告

发布于 2024-07-14 07:45:43 字数 293 浏览 10 评论 0原文

我希望创建一个报告,列出在特定时间段内关闭的所有票证。

伪代码就像

SELECT * FROM tickets
WHERE closed AND date_closed = 'january 2009'

我无法解析的部分是date_close = 'january 2009'

有没有办法在 Trac 中做到这一点?

我对特定的 SQL 语法不感兴趣,我可以自己编写时间限制。 我不确定 Trac 的数据库结构。

I wish to create a report that would list all the tickets that were closed in a certain period of time.

The pseudo-code would be like

SELECT * FROM tickets
WHERE closed AND date_closed = 'january 2009'

The part I am unable to resolve is date_closed = 'january 2009'.

Is there a way to do it in Trac?

I am not interested in particular SQL syntax, I can write the time constrictions myself. What I am not certain about is Trac's db structure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浪菊怪哟 2024-07-21 07:45:43
SELECT * FROM ticket
WHERE status='closed' 
  AND date(changetime,'unixepoch') 
      BETWEEN date('YYYY-MM-DD') /* <- here goes your start date */
          AND date('YYYY-MM-DD') /* <- here goes your end date */

如果您想要特定月份:

SELECT * FROM ticket
WHERE status='closed' 
  AND date(changetime,'unixepoch') 
      BETWEEN date('2009-01-01','start of month') 
          AND date('2009-01-01','start of month','+1 month','-1 day') 

其中 date('2009-01-01','start of Month') 是日期给定月份的第一天,date('2009 -01-01','月初','+1 月','-1 天') 是该月的最后一天。

SELECT * FROM ticket
WHERE status='closed' 
  AND date(changetime,'unixepoch') 
      BETWEEN date('YYYY-MM-DD') /* <- here goes your start date */
          AND date('YYYY-MM-DD') /* <- here goes your end date */

If you want a specific month:

SELECT * FROM ticket
WHERE status='closed' 
  AND date(changetime,'unixepoch') 
      BETWEEN date('2009-01-01','start of month') 
          AND date('2009-01-01','start of month','+1 month','-1 day') 

Where date('2009-01-01','start of month') is the first day of the month given by date, and date('2009-01-01','start of month','+1 month','-1 day') is the last day of the month.

脱离于你 2024-07-21 07:45:43
SELECT DISTINCT ticket.* FROM ticket, ticket_change
 WHERE ticket.id = ticket_change.ticket
   AND ticket_change.field = 'status'
   AND ticket_change.newvalue = 'closed'
   AND strftime('%m', ticket_change.time, 'unixepoch') = '01';

如果您还知道年份,则最好使用 vartec 建议的表达式,而不是 strftime:

SELECT DISTINCT ticket.* FROM ticket, ticket_change
 WHERE ticket.id = ticket_change.ticket
   AND ticket_change.field = 'status'
   AND ticket_change.newvalue = 'closed'
   AND date(ticket_change.time,'unixepoch') 
       BETWEEN date('2009-01-01','start of month') 
           AND date('2009-01-01','start of month','+1 month','-1 day')
SELECT DISTINCT ticket.* FROM ticket, ticket_change
 WHERE ticket.id = ticket_change.ticket
   AND ticket_change.field = 'status'
   AND ticket_change.newvalue = 'closed'
   AND strftime('%m', ticket_change.time, 'unixepoch') = '01';

If you also know the year, instead of strftime you’d better use an expression like vartec’s suggested:

SELECT DISTINCT ticket.* FROM ticket, ticket_change
 WHERE ticket.id = ticket_change.ticket
   AND ticket_change.field = 'status'
   AND ticket_change.newvalue = 'closed'
   AND date(ticket_change.time,'unixepoch') 
       BETWEEN date('2009-01-01','start of month') 
           AND date('2009-01-01','start of month','+1 month','-1 day')
回忆凄美了谁 2024-07-21 07:45:43

另外,关于表结构,这里是:

CREATE TABLE ticket_change ( 
    ticket   INTEGER,
    time     INTEGER,
    author   TEXT,
    field    TEXT,
    oldvalue TEXT,
    newvalue TEXT,
    UNIQUE ( ticket, time, field ) 
);

Also, regarding the table structure, here you go:

CREATE TABLE ticket_change ( 
    ticket   INTEGER,
    time     INTEGER,
    author   TEXT,
    field    TEXT,
    oldvalue TEXT,
    newvalue TEXT,
    UNIQUE ( ticket, time, field ) 
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文