From 028e826d49fca031091a92db0fbe67cde09d7a9b Mon Sep 17 00:00:00 2001 From: BlazingRockStorm Date: Sun, 15 Oct 2023 00:55:27 +0900 Subject: [PATCH 1/2] authenticate sidekiq --- config/routes.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 3fbf82c..3335d86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,10 @@ get '/about', to: 'home#about', as: 'about' get '/', to: 'home#index', as: 'home' - mount Sidekiq::Web, at: '/sidekiq' + authenticate :user do + mount Sidekiq::Web, at: '/sidekiq' + end + match '*unmatched', to: 'application#not_found', via: :all # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end From d24213631d559821d36012178ff27bc5c962c0b7 Mon Sep 17 00:00:00 2001 From: BlazingRockStorm Date: Mon, 16 Oct 2023 20:57:21 +0900 Subject: [PATCH 2/2] add reset database sequence --- app/jobs/reset_database_sequence_job.rb | 14 ++++++++++++++ spec/jobs/reset_database_sequence_job_spec.rb | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 app/jobs/reset_database_sequence_job.rb create mode 100644 spec/jobs/reset_database_sequence_job_spec.rb diff --git a/app/jobs/reset_database_sequence_job.rb b/app/jobs/reset_database_sequence_job.rb new file mode 100644 index 0000000..96d82d0 --- /dev/null +++ b/app/jobs/reset_database_sequence_job.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class ResetDatabaseSequenceJob < ApplicationJob + queue_as :low + + def perform(*_args) + # Do something later + # sau import, chạy rails c và reset seq: + + %w[users songs artists artists_songs genres albums].each do |tablename| + ActiveRecord::Base.connection.reset_pk_sequence!(tablename) + end + end +end diff --git a/spec/jobs/reset_database_sequence_job_spec.rb b/spec/jobs/reset_database_sequence_job_spec.rb new file mode 100644 index 0000000..b385c7e --- /dev/null +++ b/spec/jobs/reset_database_sequence_job_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ResetDatabaseSequenceJob do + pending "add some examples to (or delete) #{__FILE__}" +end