From 946a03cae791aa11040a863595af2d866a6b2918 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Tue, 16 Jan 2024 16:50:04 -0500 Subject: [PATCH 01/14] first commit --- Gemfile.lock | 1 + dump.rdb | Bin 0 -> 88 bytes 2 files changed, 1 insertion(+) create mode 100644 dump.rdb diff --git a/Gemfile.lock b/Gemfile.lock index 6fdcb5e..99d82ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -371,6 +371,7 @@ GEM PLATFORMS aarch64-linux arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..515b04053737c26c358054e5df5988477cbbc354 GIT binary patch literal 88 zcmWG?b@2=~FfcUy#aWb^l3A=1kd#?ce8AxsYjR0uZt9`8pO&Tm p;wUXnP0`Iw%{_GChycScj>P;l-K50g)B_Cv7j$%cpR?}j0s!BnB;o)7 literal 0 HcmV?d00001 From 27bb6ab4f48e715f0356dc33705a6f6ec443078b Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Tue, 16 Jan 2024 17:05:20 -0500 Subject: [PATCH 02/14] add controller and route --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index ea12f9d..b288dce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,7 @@ get "search", to: "search#index" + get "my/top-gemfiles", to: "my#top_gemfiles" # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check From 2b8f88a01e736bed8cb5b4b76b3bc27490dd54a6 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Tue, 16 Jan 2024 17:05:45 -0500 Subject: [PATCH 03/14] my controller --- app/controllers/my_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 app/controllers/my_controller.rb diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb new file mode 100644 index 0000000..12c8c54 --- /dev/null +++ b/app/controllers/my_controller.rb @@ -0,0 +1,4 @@ +class MyController < ApplicationController + def favorite_gemfiles + end +end \ No newline at end of file From ff16ea71fb922032aad3fc186f1cd8c52d31ddf5 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Tue, 16 Jan 2024 17:12:01 -0500 Subject: [PATCH 04/14] nav and link styling --- app/views/layouts/application.html.erb | 3 ++- config/routes.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9e1a070..035c7e8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -118,7 +118,8 @@ diff --git a/config/routes.rb b/config/routes.rb index b288dce..8f48997 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ get "search", to: "search#index" - get "my/top-gemfiles", to: "my#top_gemfiles" + get "my/favorite-gemfiles", to: "my#favorite_gemfiles" # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check From 9f2926a923b82d611804db9dee4f3ab5fad23d80 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Tue, 16 Jan 2024 17:17:26 -0500 Subject: [PATCH 05/14] styling --- app/views/layouts/application.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 035c7e8..730d037 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -116,10 +116,10 @@ - From 778e63ae2432350a5995c3929d7f8c2e23e629b7 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Wed, 17 Jan 2024 20:27:03 -0500 Subject: [PATCH 06/14] favorite gemfiles method --- app/controllers/my_controller.rb | 2 ++ app/models/user.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 12c8c54..29c6a15 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -1,4 +1,6 @@ class MyController < ApplicationController def favorite_gemfiles + @favorite_gemfiles = current_user.favorite_gemfiles + #current_user.favorites.map(&:favoritable).with_favorites end end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 7c429c5..5f937fc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,4 +19,8 @@ def self.from_omniauth(omniauth_params) user.save user end + + def favorite_gemfiles + Gemfile.where(id: favorites.where(favoritable_type: 'Gemfile').pluck(:favoritable_id)).with_favorites + end end From d4548e533131225924b26a382fb657a811236776 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Wed, 17 Jan 2024 20:32:00 -0500 Subject: [PATCH 07/14] sign out button styling --- app/controllers/my_controller.rb | 3 +-- app/views/layouts/application.html.erb | 2 +- app/views/my/favorite_gemfiles.erb | 10 ++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 app/views/my/favorite_gemfiles.erb diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 29c6a15..f7039ab 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -1,6 +1,5 @@ class MyController < ApplicationController def favorite_gemfiles @favorite_gemfiles = current_user.favorite_gemfiles - #current_user.favorites.map(&:favoritable).with_favorites end -end \ No newline at end of file +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 730d037..70a7254 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -119,7 +119,7 @@ diff --git a/app/views/my/favorite_gemfiles.erb b/app/views/my/favorite_gemfiles.erb new file mode 100644 index 0000000..d17755e --- /dev/null +++ b/app/views/my/favorite_gemfiles.erb @@ -0,0 +1,10 @@ +<% + title "My Favorite Gemfiles" + header_title "My Favorite Gemfiles" +%> + +
    + <% @favorite_gemfiles.each do |gemfile| %> + <%= render "gemfiles/gemfile_list_item", gemfile: gemfile %> + <% end %> +
\ No newline at end of file From 3a1cf81f912c89ffb5dea46391065721e577666d Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Thu, 18 Jan 2024 08:59:12 -0500 Subject: [PATCH 08/14] linting --- app/models/user.rb | 4 ++-- app/views/my/favorite_gemfiles.erb | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 app/views/my/favorite_gemfiles.erb diff --git a/app/models/user.rb b/app/models/user.rb index 5f937fc..b7e99fa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,8 +19,8 @@ def self.from_omniauth(omniauth_params) user.save user end - + def favorite_gemfiles - Gemfile.where(id: favorites.where(favoritable_type: 'Gemfile').pluck(:favoritable_id)).with_favorites + Gemfile.where(id: favorites.where(favoritable_type: "Gemfile").pluck(:favoritable_id)).with_favorites end end diff --git a/app/views/my/favorite_gemfiles.erb b/app/views/my/favorite_gemfiles.erb deleted file mode 100644 index d17755e..0000000 --- a/app/views/my/favorite_gemfiles.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% - title "My Favorite Gemfiles" - header_title "My Favorite Gemfiles" -%> - -
    - <% @favorite_gemfiles.each do |gemfile| %> - <%= render "gemfiles/gemfile_list_item", gemfile: gemfile %> - <% end %> -
\ No newline at end of file From 7ea9cfe02cf86d359d4fe97b5efcbe447ab7ba7d Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Thu, 18 Jan 2024 09:04:16 -0500 Subject: [PATCH 09/14] empty list message --- app/views/my/favorite_gemfiles.html.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/views/my/favorite_gemfiles.html.erb diff --git a/app/views/my/favorite_gemfiles.html.erb b/app/views/my/favorite_gemfiles.html.erb new file mode 100644 index 0000000..ea5cb17 --- /dev/null +++ b/app/views/my/favorite_gemfiles.html.erb @@ -0,0 +1,14 @@ +<% + title "My Favorite Gemfiles" + header_title "My Favorite Gemfiles" +%> + +<% if @favorite_gemfiles.present? %> +
    + <% @favorite_gemfiles.each do |gemfile| %> + <%= render "gemfiles/gemfile_list_item", gemfile: gemfile %> + <% end %> +
+<% else %> + You don't have any favorite gemfiles yet. +<% end %> \ No newline at end of file From 6bfc5c39c2a1e98241b5486be5b63d6d7dce8eb5 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Sat, 20 Jan 2024 09:23:29 -0500 Subject: [PATCH 10/14] namespace and rest --- app/controllers/my/favorites_controller.rb | 5 +++++ app/controllers/my_controller.rb | 5 ----- app/views/layouts/application.html.erb | 2 +- .../{favorite_gemfiles.html.erb => favorites/index.html.erb} | 0 config/routes.rb | 5 ++++- 5 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 app/controllers/my/favorites_controller.rb delete mode 100644 app/controllers/my_controller.rb rename app/views/my/{favorite_gemfiles.html.erb => favorites/index.html.erb} (100%) diff --git a/app/controllers/my/favorites_controller.rb b/app/controllers/my/favorites_controller.rb new file mode 100644 index 0000000..103b8f0 --- /dev/null +++ b/app/controllers/my/favorites_controller.rb @@ -0,0 +1,5 @@ +class My::FavoritesController < ApplicationController + def index + @favorite_gemfiles = current_user.favorite_gemfiles + end +end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb deleted file mode 100644 index f7039ab..0000000 --- a/app/controllers/my_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MyController < ApplicationController - def favorite_gemfiles - @favorite_gemfiles = current_user.favorite_gemfiles - end -end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 70a7254..041846b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -118,7 +118,7 @@ diff --git a/app/views/my/favorite_gemfiles.html.erb b/app/views/my/favorites/index.html.erb similarity index 100% rename from app/views/my/favorite_gemfiles.html.erb rename to app/views/my/favorites/index.html.erb diff --git a/config/routes.rb b/config/routes.rb index 8f48997..924e01f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,10 @@ get "search", to: "search#index" - get "my/favorite-gemfiles", to: "my#favorite_gemfiles" + namespace :my do + resources :favorites, only: [:index] + end + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check From 477fa22b11ff5a1e60d752770ac6ff2efabdc70c Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Sat, 20 Jan 2024 09:31:50 -0500 Subject: [PATCH 11/14] use collection partials --- app/views/gemfiles/index.html.erb | 4 +--- app/views/my/favorites/index.html.erb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/gemfiles/index.html.erb b/app/views/gemfiles/index.html.erb index a8a4ef5..8b4f333 100644 --- a/app/views/gemfiles/index.html.erb +++ b/app/views/gemfiles/index.html.erb @@ -13,7 +13,5 @@ <% end %>
    - <% @gemfiles.each do |gemfile| %> - <%= render "gemfile_list_item", gemfile: gemfile %> - <% end %> + <%= render partial: "gemfile_list_item", collection: @gemfiles, as: :gemfile %>
\ No newline at end of file diff --git a/app/views/my/favorites/index.html.erb b/app/views/my/favorites/index.html.erb index ea5cb17..0a73a73 100644 --- a/app/views/my/favorites/index.html.erb +++ b/app/views/my/favorites/index.html.erb @@ -5,9 +5,7 @@ <% if @favorite_gemfiles.present? %>
    - <% @favorite_gemfiles.each do |gemfile| %> - <%= render "gemfiles/gemfile_list_item", gemfile: gemfile %> - <% end %> + <%= render partial: "gemfiles/gemfile_list_item", collection: @favorite_gemfiles, as: :gemfile %>
<% else %> You don't have any favorite gemfiles yet. From 0af6efa5fbe2540627497c325eb22de7831661a8 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Sat, 20 Jan 2024 09:35:07 -0500 Subject: [PATCH 12/14] Don't need conditional --- app/views/my/favorites/index.html.erb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/my/favorites/index.html.erb b/app/views/my/favorites/index.html.erb index 0a73a73..8bd17f3 100644 --- a/app/views/my/favorites/index.html.erb +++ b/app/views/my/favorites/index.html.erb @@ -3,10 +3,7 @@ header_title "My Favorite Gemfiles" %> -<% if @favorite_gemfiles.present? %> -
    - <%= render partial: "gemfiles/gemfile_list_item", collection: @favorite_gemfiles, as: :gemfile %> -
-<% else %> - You don't have any favorite gemfiles yet. -<% end %> \ No newline at end of file +
    + <%= render partial: "gemfiles/gemfile_list_item", collection: @favorite_gemfiles, as: :gemfile %> + +
From a10ee860437efbdb469ee9964088d69a981125cf Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Sat, 20 Jan 2024 09:39:20 -0500 Subject: [PATCH 13/14] not needed in pr --- dump.rdb | Bin 88 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dump.rdb diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index 515b04053737c26c358054e5df5988477cbbc354..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 88 zcmWG?b@2=~FfcUy#aWb^l3A=1kd#?ce8AxsYjR0uZt9`8pO&Tm p;wUXnP0`Iw%{_GChycScj>P;l-K50g)B_Cv7j$%cpR?}j0s!BnB;o)7 From a3ea6faee59d4242edad2fe60a69b780e36fb972 Mon Sep 17 00:00:00 2001 From: Varun Kumar Date: Sat, 20 Jan 2024 09:40:24 -0500 Subject: [PATCH 14/14] rubocop --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 924e01f..4b7d4c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,9 +27,9 @@ get "search", to: "search#index" namespace :my do - resources :favorites, only: [:index] + resources :favorites, only: [ :index ] end - + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check