trac-hacks / tracstats

Project and source code statistics plugin for Trac.
http://trac-hacks.org/wiki/TracStatsPlugin
Other
20 stars 13 forks source link

Trac 1.0 Postgres not filtering by date #39

Closed mpaf closed 10 years ago

mpaf commented 10 years ago

I'm using Trac 1.0.1, and my stats don't seem to filter date (the last 30 days). They seem to give a snapshot of all development since ever. I am using a postgres backend, having migrated from sqlite.

I saw a #Fixme comment in the code, is there any action planned?

mrjbq7 commented 10 years ago

Using the last month link on the top right?

mrjbq7 commented 10 years ago

(The FIXME isn't that important, its talking about the difference between %W which is week of year [0,52] and Postgres's IW which is week of year [1,53]).

As far as I knew, the filtering was working... so if it isn't we should fix it. I will have to setup a postgres database to test with.

mpaf commented 10 years ago

Ok they do filter by date correctly when I choose stats for tickets, or wiki. But not on the Summary page. There is no link for 'last month' in that page either.

mpaf commented 10 years ago

I was looking inside my database log, and saw this statement (which I guess orders the authors by more commits in the last month). The 'WHERE' clause seems to select all revisions - since we have a negative number on the right hand side of the '>' comparison. How does that number get there?

select author, count(*)
from revision
where time / 1000000 > -2592000
group by 1
order by 2 desc
limit 10
mpaf commented 10 years ago

My older timestamps (time field in revision table) are something like: 1177751165084769

mpaf commented 10 years ago

Are these lines correct? Seems that now = 0 should be removed and that's the reason why the filtering by last 30 days is not working.

Lines 298-300 of web_ui.py:

        now = time.time()
        now = 0
        start = now - (30 * 24 * 60 * 60)
mrjbq7 commented 10 years ago

Hmm, that now = 0 looks like a bug, maybe I was using it for test purposes (introduced in 29c30d482b9edfe0b98644a4f7c5ebddca170ef0 but doesn't seem to need it). If you remove it, does last work?

mrjbq7 commented 10 years ago

Hmm, looks like that now = 0 changes the "Recent Activity (last 30 days)" to be all time. If you remove the now = 0 then it should show just the last 30 days on the top ten lists on the first page.

mpaf commented 10 years ago

This is fixed I tested it, thanks a lot!