Last active
June 9, 2016 15:24
-
-
Save camallen/be76b6f49e2835d05e34ad2c969fdb10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # IN PANOPTES | |
| # link the legacy_zoo_id (old zoo home) to the new panoptes project id | |
| migrated_ps = Project.where(migrated: true) | |
| migrated_ps.map { |p| "#{p.name} - #{p.configuration["zoo_home_project_id"]} - #{p.id}" } | |
| #=> ["penguin_watch - 35 - 55", "chimp_&_see - 41 - 60", "moon_zoo - 2 - 22", "galaxy_zoo - 1 - 21", "stardate_m83 - 29 - 49", "plankton_portal - 26 - 46", "galaxy_zoo_mergers - 4 - 24", "cyclone_center - 16 - 36", "chicago_wildlife_watch - 37 - 57", "microplants - 24 - 44", "science_gossip - 38 - 58", "whale_fm - 12 - 32", "bat_detective - 17 - 37", "asteroid_zoo - 33 - 53", "operation_war_diary - 28 - 48", "snapshot_serengeti - 20 - 40", "solar_stormwatch - 3 - 23", "ancient_lives - 10 - 30", "old_weather - 8 - 28", "galaxy_zoo_supernova - 5 - 25", "radio_galaxy_zoo - 27 - 47", "milky_way_project - 7 - 27", "worm_watch_lab - 25 - 45", "notes_from_nature - 22 - 42", "disk_detective - 30 - 50", "condor_watch - 32 - 52", "orchid_observers - 40 - 59", "ice_hunters - 9 - 29", "andromeda_project - 19 - 39", "sunspotter - 31 - 51", "seti_live - 13 - 33", "planet_four - 21 - 41", "neemo - 11 - 31", "space_warps - 23 - 43", "seafloor_explorer - 15 - 35", "planet_hunters - 6 - 26", "higgs_hunters - 36 - 56", "what's_the_score - 14 - 34", "floating_forests - 34 - 54", "cell_slider - 18 - 38"] | |
| zoo_id_mappings = migrated_ps.map { |p| legacy_project_ids[p.configuration["zoo_home_project_id"]] = p.id } | |
| zoo_id_mappings | |
| #=> {35=>55, 41=>60, 2=>22, 1=>21, 29=>49, 26=>46, 4=>24, 16=>36, 37=>57, 24=>44, 38=>58, 12=>32, 17=>37, 33=>53, 28=>48, 20=>40, 3=>23, 10=>30, 8=>28, 5=>25, 27=>47, 7=>27, 25=>45, 22=>42, 30=>50, 32=>52, 40=>59, 9=>29, 19=>39, 31=>51, 13=>33, 21=>41, 11=>31, 23=>43, 15=>35, 6=>26, 36=>56, 14=>34, 34=>54, 18=>38} | |
| # IN OUROBOROS | |
| # 1st option - If safe to mod the project zooniverse_id attribute | |
| Project.all.each do |p| | |
| p.legacy_zooniverse_id = p.zooniverse_id | |
| p.zooniverse_id = zoo_id_mappings[p.legacy_zooniverse_id] | |
| p.save | |
| end | |
| # 2nd option - If the zooniverse_id is used to link existing data | |
| Project.all.each do |p| | |
| p.panoptes_id = zoo_id_mappings[p.zooniverse_id] | |
| p.save | |
| end | |
| #option2 with atomic updates | |
| Project.all.each do |p| | |
| p.update :$set => { panoptes_id: zoo_id_mappings[p.zooniverse_id] } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment