ソースを参照

Sort activities on dashboard, clean up

Maarten van den Berg 8 年 前
コミット
88295f85d7
共有1 個のファイルを変更した15 個の追加6 個の削除を含む
  1. 15 6
      app/controllers/dashboard_controller.rb

+ 15 - 6
app/controllers/dashboard_controller.rb

@@ -2,11 +2,20 @@ class DashboardController < ApplicationController
2 2
   before_action :require_login!
3 3
 
4 4
   def home
5
-    @user_organized = current_person.participants.includes(:activity).where(is_organizer: true)
6
-    @need_response = current_person.participants.includes(:activity).where(attending: nil)
7
-    @upcoming = current_person.activities.where('start > ?', DateTime.now).includes(:participants)
8
-    @upcoming = current_person.participants
9
-      .includes(:activity).joins(:activity)
10
-      .where("activities.start >= ?", DateTime.now)
5
+    @user_organized = current_person
6
+      .participants
7
+      .joins(:activity)
8
+      .where(is_organizer: true)
9
+      .order('activities.start ASC')
10
+    @need_response = current_person
11
+      .participants
12
+      .joins(:activity)
13
+      .where(attending: nil)
14
+      .order('activities.start ASC')
15
+    @upcoming = current_person
16
+      .participants
17
+      .joins(:activity)
18
+      .where('activities.start >= ?', DateTime.now)
19
+      .order('activities.start ASC')
11 20
   end
12 21
 end