Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix re-upload a curated list

  • Loading branch information...
commit fa6663d10b19da504906205f4fc0851eeb73a345 1 parent 1076e63
Mazz Mosley mnowster authored

Showing 1 changed file with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. +10 5 app/controllers/curated_list_controller.rb
15 app/controllers/curated_list_controller.rb
@@ -43,19 +43,24 @@ def process_data_file
43 43 # eg: [sub_category_slug, artefact, artefact, artefact]
44 44 csv_obj.each do |row|
45 45 row = row.map { |k,v| v && v.strip }
46   - # lookup if curated list exists
47   - curated_list = CuratedList.any_in(tag_ids: [row[0]]).first
48   - if curated_list.nil?
49   - curated_list = CuratedList.new()
50   - # remove the slash from our tag_id
  46 + # guard against slashy data
  47 + # check if our slug starts with a slash and remove it
  48 + if row[0][0] == "/"
51 49 tag_id = row[0].slice(1..-1)
  50 + else
  51 + tag_id = row[0]
  52 + end
52 53
  54 + curated_list = CuratedList.any_in(tag_ids: [tag_id]).first
  55 + if curated_list.nil?
  56 + curated_list = CuratedList.new()
53 57 # HACKY: slug can't be empty, so for now we'll use the tag_id. Ick.
54 58 curated_list.slug = tag_id.parameterize
55 59 curated_list.sections = [tag_id]
56 60 end
57 61 artefact_slugs = row.select {|x| !x.nil?}
58 62 artefact_slugs.shift
  63 +
59 64 if artefact_slugs.length > 0
60 65 curated_list.artefact_ids = artefacts_in_order(artefact_slugs).map(&:id)
61 66 curated_list.save!

0 comments on commit fa6663d

Please sign in to comment.
Something went wrong with that request. Please try again.