Skip to content

Commit 8bb752a

Browse files
committed
dry output_dir
1 parent 657fe51 commit 8bb752a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

www/lib/tasks/movies.rake

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,27 @@ def all_claims
3131
[humans_claim] + movies
3232
end
3333

34+
def output_dir = ENV.fetch("DIR")
35+
3436
desc "Update the movie database"
3537
namespace :movies do
3638
desc "(1) Download the wiki data dump"
3739
task download: [:environment] do
3840
with_log do
39-
output_dir = ENV.fetch("DIR")
40-
4141
`curl -O https://dumps.wikimedia.org/wikidatawiki/entities/latest-all.json.bz2 --output-dir #{output_dir}`
4242
end
4343
end
4444

4545
desc "(2) Decompress the downloaded wiki data dump"
4646
task decompress: [:environment] do
4747
with_log do
48-
output_dir = ENV.fetch("DIR")
49-
5048
`(cd #{output_dir} && lbzcat latest-all.json.bz2 | rg '(#{all_claims.map { "\"#{_1}\"" }.join("|")})' > latest-all-reduced.json)`
5149
end
5250
end
5351

5452
desc "(3) Generate the movies file"
5553
task generate_movies: [:environment] do
5654
with_log do
57-
output_dir = ENV.fetch("DIR")
5855
input_file = File.join(output_dir, "latest-all-reduced.json")
5956
output_file = File.join(output_dir, "movies.json")
6057

@@ -65,7 +62,6 @@ namespace :movies do
6562
desc "(4) Generate the humans file"
6663
task generate_humans: [:environment] do
6764
with_log do
68-
output_dir = ENV.fetch("DIR")
6965
input_file = File.join(output_dir, "latest-all-reduced.json")
7066
output_file = File.join(output_dir, "humans.json")
7167

@@ -76,7 +72,6 @@ namespace :movies do
7672
desc "(5) Generate the minimized humans file"
7773
task generate_humans_minimized: [:environment] do
7874
with_log do
79-
output_dir = ENV.fetch("DIR")
8075
input_file = File.join(output_dir, "humans.json")
8176
output_file = File.join(output_dir, "humans-min.json")
8277

@@ -87,8 +82,6 @@ namespace :movies do
8782
desc "(6) Import movies from a wikidata json dump"
8883
task import: [:environment] do
8984
with_log do
90-
output_dir = ENV.fetch("DIR")
91-
9285
series_classes = File.readlines(Rails.root.join("config/wikidata_series_classes")).map(&:strip)
9386

9487
puts "Reading humans..."

0 commit comments

Comments
 (0)