mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 10:38:50 +01:00
Fix CSV reading in problem pull
This commit is contained in:
@@ -7,13 +7,13 @@ class PullProblemsJob < ApplicationJob
|
||||
PULL_URL = "https://projecteuler.net/minimal=problems;csv"
|
||||
|
||||
def perform
|
||||
csv = CSV.parse(URI.open(PULL_URL), headers: [:id, :title, :date_published, :date_last_updated, :solved_by])
|
||||
csv = CSV.parse(URI.open(PULL_URL), headers: :first_row)
|
||||
csv.each do |row|
|
||||
id = row[:id].to_i
|
||||
last_updated = Time.at(row[:date_last_updated].to_i)
|
||||
id = row["ID"].to_i
|
||||
last_updated = Time.at(row["Updated"].to_i)
|
||||
problem = Problem.where(id: id).first_or_create!
|
||||
if problem.pulled_at.nil? or problem.pulled_at < last_updated
|
||||
original_title = row[:title]
|
||||
original_title = row["Description"]
|
||||
problem.update(original_title: original_title)
|
||||
# Don't update pulled_at yet until we also successfully pulled the original_content
|
||||
PullProblemContentJob.perform_later problem
|
||||
|
||||
Reference in New Issue
Block a user