redmine-git-hosting / redmine_git_hosting

A Redmine plugin which makes configuring your own Git hosting easy ;)
http://redmine-git-hosting.io
MIT License
274 stars 117 forks source link

Mixed up dates in contributors statistics graph #211

Closed sdinot closed 10 years ago

sdinot commented 10 years ago

For testing purpose:

Dates are mixed up in the contributors statistics tab:

Contributors statistics graph

n-rodriguez commented 10 years ago

I think this is linked to http://www.redmine.org/issues/5357

The revision order in git is provided only by the linked list nature of revisions, i.e. a revision holds a reference to its parent revision, which in turn holds a reference to its parent, and so on.

I don't know if it can be easily fixed.

n-rodriguez commented 10 years ago

I've done the test and it seems to work:

dpt - statistiques - test1 - redmine

Which version of Redmine are you running?

sdinot commented 10 years ago

Hi Nicolas,

Thank you for investigating this issue.

I am not familiar with the database model of Redmine but what do you think about the following kind of query ?

SELECT c.commit_date AS date, COUNT(c.id) AS changes FROM changesets AS c JOIN repositories AS r ON c.repository_id = r.id JOIN users AS u ON c.user_id = u.id WHERE r.identifier = 'zoinx-orekit' AND u.mail = 'luc@orekit.org' GROUP BY c.commit_date ORDER BY c.commit_date DESC;

date changes
2014-05-27 2
2014-05-16 7
2014-05-15 2
2014-05-14 2
2014-05-06 1
2014-04-09 2
2014-04-07 2
2014-03-21 2
2014-03-09 3
2014-03-07 2
2014-03-01 1
... ...
sdinot commented 10 years ago

Administration => Informations:

sdinot commented 10 years ago

I think that I have found the problem. There are some missing ".order(:commit_date)" in the repository_patch.rb file:

https://www.dinot.net/tmp/order_by_commit_date.diff

n-rodriguez commented 10 years ago

I've tested your patch and it's still working for me :) Does it work for you?

sdinot commented 10 years ago

Yes, my patch works for me. I use PostgreSQL, do you use MySQL? If that is the case, maybe that MySQL returns ordered results when a GROUP BY clause is used but not PostgreSQL.

n-rodriguez commented 10 years ago

I use PostgreSQL, do you use MySQL? If that is the case, maybe that MySQL returns ordered results when a GROUP BY clause is used but not PostgreSQL.

Maybe. That's very possible. In all cases it will be in next release (v0.7.4) ;)

Thank you!