diff --git a/app/models/logfile.rb b/app/models/logfile.rb deleted file mode 100644 index 77aacbd7b..000000000 --- a/app/models/logfile.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Logfile < ApplicationRecord - belongs_to :report - validates :report_id, :presence => true - validates :ext, - :uniqueness => { :scope => :report_id }, - :inclusion => { :in => %w[log.txt diff.txt log.html diff.html], - :message => "%{value} is not a valid ext" } - validates :data, :presence => true - - def uri - r = report - t = r.datetime.strftime('%Y%m%dT%H%M%SZ') - "#{r.server.uri}ruby-#{r.branch}/log/#{t}.#{ext}.gz" - end -end diff --git a/db/migrate/20260727095902_drop_logfiles.rb b/db/migrate/20260727095902_drop_logfiles.rb new file mode 100644 index 000000000..f1091df86 --- /dev/null +++ b/db/migrate/20260727095902_drop_logfiles.rb @@ -0,0 +1,13 @@ +class DropLogfiles < ActiveRecord::Migration[8.1] + def change + drop_table :logfiles do |t| + t.datetime :created_at, precision: nil + t.binary :data + t.string :ext + t.integer :report_id + t.datetime :updated_at, precision: nil + t.index [:report_id, :ext], name: "index_logfiles_on_report_id_and_ext", unique: true + t.index [:report_id], name: "index_logfiles_on_report_id" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d652c675d..600b9eb82 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[8.1].define(version: 2026_07_27_051843) do +ActiveRecord::Schema[8.1].define(version: 2026_07_27_095902) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -42,16 +42,6 @@ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end - create_table "logfiles", force: :cascade do |t| - t.datetime "created_at", precision: nil - t.binary "data" - t.string "ext" - t.integer "report_id" - t.datetime "updated_at", precision: nil - t.index ["report_id", "ext"], name: "index_logfiles_on_report_id_and_ext", unique: true - t.index ["report_id"], name: "index_logfiles_on_report_id" - end - create_table "recents", force: :cascade do |t| t.datetime "created_at", null: false t.string "etag", null: false diff --git a/lib/tasks/scheduler.rake b/lib/tasks/scheduler.rake index c4c045144..47279869a 100644 --- a/lib/tasks/scheduler.rake +++ b/lib/tasks/scheduler.rake @@ -28,39 +28,6 @@ task :inspect_env => :environment do p URI("http://www.yahoo.co.jp").read(100) rescue nil end -desc "fetch old logfiles" -task :fetch_logfile => :environment do - Report. - joins("LEFT OUTER JOIN logfiles AS l1 ON - reports.id = l1.report_id AND l1.ext='log.txt'"). - joins("LEFT OUTER JOIN logfiles AS l2 ON - reports.id = l2.report_id AND l2.ext='diff.txt'"). - joins("LEFT OUTER JOIN logfiles AS l3 ON - reports.id = l2.report_id AND l3.ext='log.html'"). - joins("LEFT OUTER JOIN logfiles AS l4 ON - reports.id = l4.report_id AND l4.ext='diff.html'"). - where('l1.report_id IS NULL OR l2.report_id IS NULL OR - l3.report_id IS NULL OR l4.report_id IS NULL'). - where('reports.server_id = 4'). - select(['reports.*', - 'l1.id AS l1id', 'l2.id AS l2id', 'l3.id AS l3id', 'l4.id AS l4id']). - find_each do |r| - t = r.datetime.strftime('%Y%m%dT%H%M%SZ') - lids = [r.l1id, r.l2id, r.l3id, r.l4id] - %w[log.txt diff.txt log.html diff.html].each_with_index do |ext, i| - next if lids[i] - uri = "#{r.server.uri}ruby-#{r.branch}/log/#{t}.#{ext}.gz" - puts uri - begin - data = URI(uri).read - Logfile.create(report_id: r.id, ext: ext, data: data) - rescue => e - p e - end - end - end -end - desc "sync server settings" task :sync_servers => :environment do require 'open-uri'