I linked to the Russian Losses App many times in various internet arguments. It doesn't currently have a permanent URL for the latest version, and various versions just reflect state of the code at given point.
It makes sense to keep the code as is, but I still want each version to have the latest data. So I wrote this script:
#!/usr/bin/env ruby
require "pathname"
class UpdateCSV
def initialize(archive_path)
@archive_path = Pathname(archive_path)
end
def updated_equipment
@updated_equipment ||= (@archive_path + "russia_losses_equipment.csv").read
end
def updated_personnel
@updated_personnel ||= (@archive_path + "russia_losses_personnel.csv").read
end
def csv_files
@csv_files ||= `git ls`.lines.map(&:chomp).grep(/\.csv\z/)
end
def call
csv_files.each do |path|
case path
when /russia_losses_equipment/
Pathname(path).write(updated_equipment)
when /russia_losses_personnel/
Pathname(path).write(updated_personnel)
else
puts "Unknown CSV file: #{path}"
end
end
end
end
unless ARGV[0]
STDERR.puts "Usage: #{$0} path_to_updated_archive"
exit 1
end
UpdateCSV.new(ARGV[0]).call
To run it, I grab updated version from Kaggle, unpack it, and then run the update script.
There's a lot of files it needs to update. The ones in docs
are GitHub Pages compiled app:
docs/episode-29/tanks/russia_losses_equipment.csv
docs/episode-29/tanks/russia_losses_personnel.csv
docs/episode-30/russia_losses_equipment.982e4e03.csv
docs/episode-31/russia_losses_equipment.csv
docs/episode-31/russia_losses_personnel.csv
docs/episode-32/russia_losses_equipment.csv
docs/episode-32/russia_losses_personnel.csv
docs/episode-33/russia_losses_equipment.csv
docs/episode-33/russia_losses_personnel.csv
docs/episode-34/russia_losses_equipment.csv
docs/episode-34/russia_losses_personnel.csv
docs/episode-35/russia_losses_equipment.csv
docs/episode-35/russia_losses_personnel.csv
docs/episode-36/russia_losses_equipment.csv
docs/episode-36/russia_losses_personnel.csv
episode-29/tanks/russia_losses_equipment.csv
episode-29/tanks/russia_losses_personnel.csv
episode-30/src/russia_losses_equipment.csv
episode-30/src/russia_losses_personnel.csv
episode-31/public/russia_losses_equipment.csv
episode-31/public/russia_losses_personnel.csv
episode-32/public/russia_losses_equipment.csv
episode-32/public/russia_losses_personnel.csv
episode-33/public/russia_losses_equipment.csv
episode-33/public/russia_losses_personnel.csv
episode-34/public/russia_losses_equipment.csv
episode-34/public/russia_losses_personnel.csv
episode-35/public/russia_losses_equipment.csv
episode-35/public/russia_losses_personnel.csv
episode-36/public/russia_losses_equipment.csv
episode-36/public/russia_losses_personnel.csv
Coming next
Over the next few episodes, I want to add a few new features to the Russian losses tracker.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.