25 lines
530 B
Ruby
25 lines
530 B
Ruby
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# SPDX-FileCopyrightText: 2023 Hugo Peixoto <hugo.peixoto@gmail.com>
|
|
|
|
require 'json'
|
|
require './database.rb'
|
|
require './models.rb'
|
|
|
|
i = 0
|
|
k = 2000
|
|
File.readlines(ARGV[0]).each_slice(k) do |lines|
|
|
start = Time.now
|
|
|
|
ActiveRecord::Base.transaction do
|
|
lines.each do |line|
|
|
metadata = JSON.parse(line)
|
|
Video.where(randname: metadata["randname"]).first_or_create({ metadata: metadata })
|
|
end
|
|
end
|
|
|
|
finish = Time.now
|
|
|
|
i += k
|
|
puts "done #{i} (#{finish - start})"
|
|
end
|