diff --git a/Gemfile b/Gemfile index 76d9bc5..a8a4af7 100644 --- a/Gemfile +++ b/Gemfile @@ -56,7 +56,8 @@ gem "ahoy_matey", "~> 5.2" gem "ruby-openai", "~> 7.3" gem "httparty", "~> 0.22.0" gem "down", "~> 5.4" -gem "aws-sdk-s3", "~> 1.177" +gem "aws-sdk-s3", "~> 1.170" +gem "aws-sdk-core", "3.211" gem "sidekiq", "~> 7.3" gem "sidekiq-scheduler", "~> 5.0" diff --git a/Gemfile.lock b/Gemfile.lock index 3c8750f..a88d71d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,16 +94,16 @@ GEM ast (2.4.2) aws-eventstream (1.3.0) aws-partitions (1.1044.0) - aws-sdk-core (3.217.1) + aws-sdk-core (3.211.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.97.0) - aws-sdk-core (~> 3, >= 3.216.0) + aws-sdk-kms (1.96.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.179.0) - aws-sdk-core (~> 3, >= 3.216.0) + aws-sdk-s3 (1.177.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) aws-sigv4 (1.11.0) @@ -511,7 +511,8 @@ PLATFORMS DEPENDENCIES activeadmin (~> 3.2) ahoy_matey (~> 5.2) - aws-sdk-s3 (~> 1.177) + aws-sdk-core (= 3.211) + aws-sdk-s3 (~> 1.170) bootsnap brakeman capybara diff --git a/db/schema.rb b/db/schema.rb index 9ce0fbd..ce7a67c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,13 +11,16 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do + # These are extensions that must be enabled in order to support this database + enable_extension "pg_catalog.plpgsql" + create_table "active_admin_comments", force: :cascade do |t| t.string "namespace" t.text "body" t.string "resource_type" - t.integer "resource_id" + t.bigint "resource_id" t.string "author_type" - t.integer "author_id" + t.bigint "author_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author" @@ -66,8 +69,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do end create_table "ahoy_events", force: :cascade do |t| - t.integer "visit_id" - t.integer "user_id" + t.bigint "visit_id" + t.bigint "user_id" t.string "name" t.text "properties" t.datetime "time" @@ -79,7 +82,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do create_table "ahoy_visits", force: :cascade do |t| t.string "visit_token" t.string "visitor_token" - t.integer "user_id" + t.bigint "user_id" t.string "ip" t.text "user_agent" t.text "referrer" @@ -117,12 +120,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "slug" - t.integer "country_id", null: false + t.bigint "country_id", null: false t.string "state_code" t.string "country_code" t.boolean "flag", default: true t.string "wiki_data_id" - t.integer "state_id" + t.bigint "state_id" t.index ["country_id"], name: "index_cities_on_country_id" t.index ["slug"], name: "index_cities_on_slug", unique: true t.index ["state_id"], name: "index_cities_on_state_id" @@ -132,7 +135,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do t.string "name" t.string "code" t.string "slug" - t.integer "region_id" + t.bigint "region_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "iso3" @@ -155,7 +158,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do t.string "emoji_u" t.boolean "flag", default: true t.string "wiki_data_id" - t.integer "subregion_id" + t.bigint "subregion_id" t.index ["code"], name: "index_countries_on_code", unique: true t.index ["region_id"], name: "index_countries_on_region_id" t.index ["slug"], name: "index_countries_on_slug", unique: true @@ -189,7 +192,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do create_table "states", force: :cascade do |t| t.string "name" t.string "code" - t.integer "country_id" + t.bigint "country_id" t.string "country_code" t.string "fips_code" t.string "iso2" @@ -208,7 +211,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do create_table "subregions", force: :cascade do |t| t.string "name", null: false t.text "translations" - t.integer "region_id", null: false + t.bigint "region_id", null: false t.boolean "flag", default: true t.string "wiki_data_id" t.datetime "created_at", null: false @@ -217,7 +220,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do end create_table "weather_arts", force: :cascade do |t| - t.integer "city_id", null: false + t.bigint "city_id", null: false t.date "weather_date" t.string "description" t.decimal "temperature" diff --git a/lib/tasks/sync_geo_data.rake b/lib/tasks/sync_geo_data.rake index afb6376..2e4490f 100644 --- a/lib/tasks/sync_geo_data.rake +++ b/lib/tasks/sync_geo_data.rake @@ -84,7 +84,8 @@ namespace :geo do count += 1 # 查找或初始化 Country - country = Country.find_or_initialize_by(name: data["name"]) do |c| + country = Country.find_or_create_by(code: data["iso2"]) do |c| + c.name = data["name"] end # 更新 Country 属性