From 581f7b1d13b0b5c4abe9365799edfe744df45b68 Mon Sep 17 00:00:00 2001 From: Bogdan Moise Date: Thu, 25 Aug 2022 22:52:27 +0300 Subject: [PATCH 1/2] Improve scores feed performance --- .gitignore | 2 ++ Gemfile.lock | 2 +- app/controllers/api/scores_controller.rb | 2 +- spec/spec_helper.rb | 12 ++++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 035ad25..dcee572 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ /config/database.yml .DS_Store /storage/* + +.idea/ diff --git a/Gemfile.lock b/Gemfile.lock index 982a4b6..3f372d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,7 +228,7 @@ GEM zeitwerk (2.6.0) PLATFORMS - x86_64-darwin-20 + x86_64-darwin-21 DEPENDENCIES bootsnap (>= 1.4.4) diff --git a/app/controllers/api/scores_controller.rb b/app/controllers/api/scores_controller.rb index cbed318..5e95873 100644 --- a/app/controllers/api/scores_controller.rb +++ b/app/controllers/api/scores_controller.rb @@ -5,7 +5,7 @@ class ScoresController < ApplicationController before_action :validate_score_user_id, only: :destroy def user_feed - scores = Score.all.order(played_at: :desc, id: :desc) + scores = Score.all.order(played_at: :desc, id: :desc).includes(:user) serialized_scores = scores.map(&:serialize) response = { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce334c7..07fab7f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,12 +69,12 @@ # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - # config.default_formatter = "doc" - end + # if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running From ac74781cb9002cafa11fec1bddeaa1c5aab8a90a Mon Sep 17 00:00:00 2001 From: Bogdan Moise Date: Thu, 25 Aug 2022 23:50:22 +0300 Subject: [PATCH 2/2] Change Gemfile.lock --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3f372d6..982a4b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,7 +228,7 @@ GEM zeitwerk (2.6.0) PLATFORMS - x86_64-darwin-21 + x86_64-darwin-20 DEPENDENCIES bootsnap (>= 1.4.4)