From e37cde2f0d91fa6678f4b38c55a8cc2f99604abe Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Fri, 25 Feb 2022 15:39:56 +0100 Subject: [PATCH] removes dead code about OpenAPI (open_api_calls_count_tracings) --- CHANGELOG.md | 1 + app/models/open_api/calls_count_tracing.rb | 4 --- app/models/open_api/client.rb | 2 -- .../open_api_trace_calls_count_worker.rb | 10 ------ config/schedule.yml | 4 --- ...rop_table_open_api_calls_count_tracings.rb | 14 +++++++++ db/schema.rb | 31 ++++++------------- 7 files changed, 25 insertions(+), 41 deletions(-) delete mode 100644 app/models/open_api/calls_count_tracing.rb delete mode 100644 app/workers/open_api_trace_calls_count_worker.rb create mode 100644 db/migrate/20220225143203_drop_table_open_api_calls_count_tracings.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index d764f7c34..995beb784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix line break on home events' cards - fix typo "projets" => "projects" +- removes dead code about OpenAPI (open_api_calls_count_tracings) ## v5.3.3 2022 February 08 diff --git a/app/models/open_api/calls_count_tracing.rb b/app/models/open_api/calls_count_tracing.rb deleted file mode 100644 index c54338a12..000000000 --- a/app/models/open_api/calls_count_tracing.rb +++ /dev/null @@ -1,4 +0,0 @@ -class OpenAPI::CallsCountTracing < ApplicationRecord - belongs_to :projets, foreign_key: :open_api_client_id - validates :projets, :at, presence: true -end diff --git a/app/models/open_api/client.rb b/app/models/open_api/client.rb index a9815eaf7..9d537d379 100644 --- a/app/models/open_api/client.rb +++ b/app/models/open_api/client.rb @@ -2,8 +2,6 @@ # OpenAPI::Client keeps track of the authorized accesses to the 3-rd party API (aka. OpenAPI) class OpenAPI::Client < ApplicationRecord - has_many :calls_count_tracings, foreign_key: :open_api_client_id, dependent: :destroy - validates :name, presence: true validates_uniqueness_of :token diff --git a/app/workers/open_api_trace_calls_count_worker.rb b/app/workers/open_api_trace_calls_count_worker.rb deleted file mode 100644 index d54569567..000000000 --- a/app/workers/open_api_trace_calls_count_worker.rb +++ /dev/null @@ -1,10 +0,0 @@ -class OpenAPITraceCallsCountWorker < Sidekiq::Workers - include Sidekiq::Worker - sidekiq_options queue: 'default', retry: true - - def perform - OpenAPI::Client.find_each do |client| - OpenAPI::CallsCountTracing.create!(projets: client, calls_count: client.calls_count, at: DateTime.current) - end - end -end diff --git a/config/schedule.yml b/config/schedule.yml index af0ecf6b4..d1bb8b1c6 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -20,10 +20,6 @@ i_calendar_import: class: "ICalendarImportWorker" queue: default -open_api_trace_calls_count: - cron: "0 4 * * 0" # every sunday at 4am - class: "OpenAPITraceCallsCountWorker" - reservation_reminder: cron: "1 * * * *" class: "ReservationReminderWorker" diff --git a/db/migrate/20220225143203_drop_table_open_api_calls_count_tracings.rb b/db/migrate/20220225143203_drop_table_open_api_calls_count_tracings.rb new file mode 100644 index 000000000..444074bce --- /dev/null +++ b/db/migrate/20220225143203_drop_table_open_api_calls_count_tracings.rb @@ -0,0 +1,14 @@ +class DropTableOpenAPICallsCountTracings < ActiveRecord::Migration[5.2] + def up + drop_table :open_api_calls_count_tracings + end + + def down + create_table :open_api_calls_count_tracings do |t| + t.belongs_to :open_api_client, foreign_key: true, index: true + t.integer :calls_count, null: false + t.datetime :at, null: false + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index eaef1c8e7..af2f63d2f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_01_18_123741) do +ActiveRecord::Schema.define(version: 2022_02_25_143203) do # These are extensions that must be enabled in order to support this database enable_extension "fuzzystrmatch" @@ -19,8 +19,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do enable_extension "unaccent" create_table "abuses", id: :serial, force: :cascade do |t| - t.integer "signaled_id" t.string "signaled_type" + t.integer "signaled_id" t.string "first_name" t.string "last_name" t.string "email" @@ -49,8 +49,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do t.string "locality" t.string "country" t.string "postal_code" - t.integer "placeable_id" t.string "placeable_type" + t.integer "placeable_id" t.datetime "created_at" t.datetime "updated_at" end @@ -64,8 +64,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do end create_table "assets", id: :serial, force: :cascade do |t| - t.integer "viewable_id" t.string "viewable_type" + t.integer "viewable_id" t.string "attachment" t.string "type" t.datetime "created_at" @@ -133,8 +133,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do end create_table "credits", id: :serial, force: :cascade do |t| - t.integer "creditable_id" t.string "creditable_type" + t.integer "creditable_id" t.integer "plan_id" t.integer "hours" t.datetime "created_at" @@ -356,15 +356,15 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do create_table "notifications", id: :serial, force: :cascade do |t| t.integer "receiver_id" - t.integer "attached_object_id" t.string "attached_object_type" + t.integer "attached_object_id" t.integer "notification_type_id" t.boolean "is_read", default: false t.datetime "created_at" t.datetime "updated_at" t.string "receiver_type" t.boolean "is_send", default: false - t.jsonb "meta_data", default: {} + t.jsonb "meta_data", default: "{}" t.index ["notification_type_id"], name: "index_notifications_on_notification_type_id" t.index ["receiver_id"], name: "index_notifications_on_receiver_id" end @@ -402,15 +402,6 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do t.index ["subscription_id"], name: "index_offer_days_on_subscription_id" end - create_table "open_api_calls_count_tracings", id: :serial, force: :cascade do |t| - t.integer "open_api_client_id" - t.integer "calls_count", null: false - t.datetime "at", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["open_api_client_id"], name: "index_open_api_calls_count_tracings_on_open_api_client_id" - end - create_table "open_api_clients", id: :serial, force: :cascade do |t| t.string "name" t.integer "calls_count", default: 0 @@ -492,7 +483,6 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do t.integer "weight" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.text "description" end create_table "plans", id: :serial, force: :cascade do |t| @@ -550,8 +540,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do create_table "prices", id: :serial, force: :cascade do |t| t.integer "group_id" t.integer "plan_id" - t.integer "priceable_id" t.string "priceable_type" + t.integer "priceable_id" t.integer "amount" t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -661,8 +651,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do t.text "message" t.datetime "created_at" t.datetime "updated_at" - t.integer "reservable_id" t.string "reservable_type" + t.integer "reservable_id" t.integer "nb_reserve_places" t.integer "statistic_profile_id" t.index ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id" @@ -671,8 +661,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do create_table "roles", id: :serial, force: :cascade do |t| t.string "name" - t.integer "resource_id" t.string "resource_type" + t.integer "resource_id" t.datetime "created_at" t.datetime "updated_at" t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" @@ -1009,7 +999,6 @@ ActiveRecord::Schema.define(version: 2022_01_18_123741) do add_foreign_key "invoices", "wallet_transactions" add_foreign_key "invoicing_profiles", "users" add_foreign_key "o_auth2_mappings", "o_auth2_providers" - add_foreign_key "open_api_calls_count_tracings", "open_api_clients" add_foreign_key "organizations", "invoicing_profiles" add_foreign_key "payment_gateway_objects", "payment_gateway_objects" add_foreign_key "payment_schedule_items", "invoices"