From 904e728c4a96d0ec3c676a2b727e5a1cec5cbe3a Mon Sep 17 00:00:00 2001 From: Kenneth Bogner Date: Mon, 3 Jun 2024 23:57:06 -0400 Subject: [PATCH] Add historical match filter --- .gitignore | 2 ++ app/controllers/recent_matches_controller.rb | 10 ++++++++ .../recent_matches/_historical_match.html.erb | 24 +++++++++++++++++++ app/views/recent_matches/filter.html.erb | 13 ++++++++++ config/routes.rb | 1 + 5 files changed, 50 insertions(+) create mode 100644 app/views/recent_matches/_historical_match.html.erb create mode 100644 app/views/recent_matches/filter.html.erb diff --git a/.gitignore b/.gitignore index abced15..aea16bd 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ !/app/assets/builds/.keep .irb_history + +.DS_Store diff --git a/app/controllers/recent_matches_controller.rb b/app/controllers/recent_matches_controller.rb index 99e754a..e838670 100644 --- a/app/controllers/recent_matches_controller.rb +++ b/app/controllers/recent_matches_controller.rb @@ -5,6 +5,12 @@ def index @recent_matches = CollectsRecentMatchesForUser.new.call(user: @current_user) end + def filter + load_current_user_profile + + @historical_matches = HistoricalMatch.where(filter_params).order(matched_on: :desc) + end + private def load_current_user_profile @@ -15,4 +21,8 @@ def load_current_user_profile @user_profile = SlackUserProfile.find_by(slack_user_id: @current_user.slack_user_id) end + + def filter_params + params.permit(:grouping) + end end diff --git a/app/views/recent_matches/_historical_match.html.erb b/app/views/recent_matches/_historical_match.html.erb new file mode 100644 index 0000000..36fc647 --- /dev/null +++ b/app/views/recent_matches/_historical_match.html.erb @@ -0,0 +1,24 @@ +
+
+
+ <% historical_match.profiled_members.each do |member| %> + <%= link_to profile_path(member.slack_user_id) do %> +
+ + <%= member.name %> +
+ <% end %> + <% end %> +
+
+
+ <%= historical_match.grouping.titleize %> +
+
+
+ <%= historical_match.matched_on.strftime("%b %d, %Y") %> +
+
+
+
+
\ No newline at end of file diff --git a/app/views/recent_matches/filter.html.erb b/app/views/recent_matches/filter.html.erb new file mode 100644 index 0000000..9343bb1 --- /dev/null +++ b/app/views/recent_matches/filter.html.erb @@ -0,0 +1,13 @@ +
+
+

Historical matches

+
+ +
+ <% if @historical_matches.empty? %> +

No matches made yet

+ <% else %> + <%= render partial: "historical_match", collection: @historical_matches %> + <% end %> +
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ddbfac6..b9d9ab7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ root to: "root#index" get "/matches", to: "recent_matches#index", as: "recent_matches" + get "/matches/filter", to: "recent_matches#filter", as: "filter_recent_matches" get "/profile/:slack_user_id", to: "profile#show", as: "profile" resources :calendar_links, except: [:show]