Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-23 12:13:33 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-23 12:13:33 +0400
commit1df0345e9e642ca7e9d73c12430921b0fe62d25e (patch)
treefc2584e67ce95d8f832420a3df0f7594a475d359 /app/finders
parent6b4d5d21be69705f22cb2e848fdba9f182ef2bc5 (diff)
Explore area
Create one place for exploring GitLab instance projects and groups for both signed in and anonymous users Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/trending_projects_finder.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/finders/trending_projects_finder.rb b/app/finders/trending_projects_finder.rb
new file mode 100644
index 00000000000..32d7968924a
--- /dev/null
+++ b/app/finders/trending_projects_finder.rb
@@ -0,0 +1,19 @@
+class TrendingProjectsFinder
+ def execute(current_user, start_date = nil)
+ start_date ||= Date.today - 1.month
+
+ projects = projects_for(current_user)
+
+ # Determine trending projects based on comments count
+ # for period of time - ex. month
+ projects.joins(:notes).where('notes.created_at > ?', start_date).
+ select("projects.*, count(notes.id) as ncount").
+ group("projects.id").order("ncount DESC")
+ end
+
+ private
+
+ def projects_for(current_user)
+ ProjectsFinder.new.execute(current_user)
+ end
+end