diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-08-17 15:22:17 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-08-17 15:22:17 +0300 |
commit | 74eec89ebe0b118f8aba6051f53d5dbe5e68c2d1 (patch) | |
tree | 66ed7128fa11bcc7097a2f6e68b8280a4f25eb1c /lib | |
parent | 65d48623e2d39bb0174e707f9cd3bea5db8c50d1 (diff) | |
parent | 7336bd4843521956997c80a10705a83083eb122b (diff) |
Merge branch 'repopulate_site_statistics' into 'master'
Fix SiteStatistics wikis_count
See merge request gitlab-org/gitlab-ce!21030
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/gitlab/site_statistics.rake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/site_statistics.rake b/lib/tasks/gitlab/site_statistics.rake new file mode 100644 index 00000000000..7d24ec72a9d --- /dev/null +++ b/lib/tasks/gitlab/site_statistics.rake @@ -0,0 +1,23 @@ +namespace :gitlab do + desc "GitLab | Refresh Site Statistics counters" + task refresh_site_statistics: :environment do + puts 'Updating Site Statistics counters: ' + + print '* Repositories... ' + SiteStatistic.transaction do + # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + ActiveRecord::Base.connection.execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? + SiteStatistic.update_all('repositories_count = (SELECT COUNT(*) FROM projects)') + end + puts 'OK!'.color(:green) + + print '* Wikis... ' + SiteStatistic.transaction do + # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + ActiveRecord::Base.connection.execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? + SiteStatistic.update_all('wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)') + end + puts 'OK!'.color(:green) + puts + end +end |