Skip to content

Instantly share code, notes, and snippets.

@kjell
Last active October 10, 2016 20:30
Show Gist options
  • Save kjell/b3a3318b0b0f38221e03bf0a398621ce to your computer and use it in GitHub Desktop.
Save kjell/b3a3318b0b0f38221e03bf0a398621ce to your computer and use it in GitHub Desktop.
var fs = require('fs')
var execSync = require('child_process').execSync
// map loan accessions to ids - we can't search objects that aren't 'public_access: 1'
var loans = {
'L2005.76.2': '97072',
'L2014.234.4': '120481',
'L2014.234.70': '120547',
'L2014.184': '120000',
'L2014.399': '120104'
}
var data = fs.readFileSync('./journeys-accession.json', 'utf8')
var json = JSON.parse(data)
var out = json.map((journey) => {
var objectsById = journey.objects.map(acc => {
// trailing letters need to be lowercase for search, but a leading L/P needs to remain uppercase
var massagedAcc = acc.toLowerCase().replace(/^l/, 'L').replace(/^p/, 'P')
var id = loans[acc] || execSync(`mia 'accession_number:"${massagedAcc}"' | jq -r '.id'`, {encoding: 'utf8'}).trim()
return id || acc
})
journey.objects = objectsById
journey.user_id = 0
journey.object_count = objectsById.length
return journey
})
console.info(JSON.stringify(out))
[ { "title": "Lakes & Streams",
"description": "Whether it’s a stream quietly running through the woods, the vast expanse of Lake Superior, or the Mighty Mississippi, there’s something undeniably magical about humans' connection to water. The theme of The Growler's June 2016 issue is Lakes & Streams, and the works chosen for this Journey highlight some of the magazine staff's favorite pieces in the museum—some literal, some utilitarian, some abstract—that fit that theme.",
"objects": [
"73.42.2",
"75.24",
"98.125",
"2004.211",
"2006.1",
"2011.29",
"2012.45",
"2014.51.1A,B",
"2014.148.20"
]
},
{ "title": "Robyne Robinson's Journey",
"description": "Robyne Robinson has been a well-known personality in the Twin Cities for more than 20 years. An award-winning pioneer in Minnesota broadcasting and state politics, Robinson was the first black prime time news anchor in the Minneapolis – St. Paul TV market and only the second African-American to run for Lt. Governor of Minnesota. She’s also known as a staunch advocate for Minnesota arts, as well as an international jewelry designer. Robinson currently serves as Arts and Culture Director of the Airport Foundation MSP at Minneapolis-St. Paul International Airport. This journey features her favorite works in the museum's collection.",
"objects": [
"2012.25",
"89.14",
"27.42.4",
"97.73.2.1",
"97.73.11.1",
"91.141.17",
"2003.186",
"2011.52",
"96.115",
"2011.1",
"2014.93.3A,B",
"2014.93.2",
"90.58.177",
"90.58.176",
"90.58.175",
"82.10.4",
"28.24.198"
]
},
{ "title": "Doctor Fink's Journey",
"description": "Matt Fink, better known by the stage name Doctor Fink, and as a leading member of Prince’s band, The Revolution, is a Grammy-award-winning keyboardist, record producer and songwriter. A longtime fan of the museum and the collection, this journey features his favorite works of art.",
"objects": [
"2012.31.1A-C",
"56.33",
"16.414",
"2001.80.1",
"93.42",
"2012.68.1A,B",
"2009.7",
"2005.138",
"96.2",
"84.5",
"69.137",
"64.43.2",
"54.1",
"70.60",
"41.2",
"72.11",
"82.43.10",
"2011.28"
]
},
{ "title": "Jamie Yuccas's Journey",
"description": "Former WCCO This Morning anchor and current CBS News Correspondent, Jamie Yuccas is a Minnesota native, experienced journalist, and novice museum tour guide. This journey features works of art that she finds inspiring.",
"objects": [
"2007.100",
"L2005.76.2",
"79.12.23",
"2001.293.4",
"2001.293.5",
"2012.77a-d",
"96.2",
"65.5",
"55.27a-c",
"L2014.234.4",
"L2014.234.70",
"L2014.184",
"2014.81",
"P.90.29.2",
"L2014.399",
"42.8.296",
"2012.68.1a,b",
"93.42",
"2012.112.19",
"2010.72",
"2003.198"
]
}
]
[
{
"title": "Lakes & Streams",
"description": "Whether it’s a stream quietly running through the woods, the vast expanse of Lake Superior, or the Mighty Mississippi, there’s something undeniably magical about humans' connection to water. The theme of The Growler's June 2016 issue is Lakes & Streams, and the works chosen for this Journey highlight some of the magazine staff's favorite pieces in the museum—some literal, some utilitarian, some abstract—that fit that theme.",
"objects": [
"1977",
"2175",
"9405",
"91556",
"98663",
"111879",
"106831",
"119697",
"120945"
],
"user_id": 0,
"object_count": 9
},
{
"title": "Robyne Robinson's Journey",
"description": "Robyne Robinson has been a well-known personality in the Twin Cities for more than 20 years. An award-winning pioneer in Minnesota broadcasting and state politics, Robinson was the first black prime time news anchor in the Minneapolis – St. Paul TV market and only the second African-American to run for Lt. Governor of Minnesota. She’s also known as a staunch advocate for Minnesota arts, as well as an international jewelry designer. Robinson currently serves as Arts and Culture Director of the Airport Foundation MSP at Minneapolis-St. Paul International Airport. This journey features her favorite works in the museum's collection.",
"objects": [
"114035",
"3817",
"328",
"29934",
"29932",
"4177",
"83511",
"112568",
"4959",
"111380",
"120378",
"120377",
"26814",
"26813",
"3993",
"2991",
"353"
],
"user_id": 0,
"object_count": 17
},
{
"title": "Doctor Fink's Journey",
"description": "Matt Fink, better known by the stage name Doctor Fink, and as a leading member of Prince’s band, The Revolution, is a Grammy-award-winning keyboardist, record producer and songwriter. A longtime fan of the museum and the collection, this journey features his favorite works of art.",
"objects": [
"114440",
"1312",
"95",
"45640",
"4553",
"115749",
"107115",
"98653",
"5033",
"3291",
"1721",
"1554",
"1239",
"12092",
"592",
"19689",
"23274",
"111675"
],
"user_id": 0,
"object_count": 18
},
{
"title": "Jamie Yuccas's Journey",
"description": "Former WCCO This Morning anchor and current CBS News Correspondent, Jamie Yuccas is a Minnesota native, experienced journalist, and novice museum tour guide. This journey features works of art that she finds inspiring.",
"objects": [
"102644",
"97072",
"2606",
"45535",
"45536",
"115836",
"5033",
"1595",
"1270",
"120481",
"120547",
"120000",
"119994",
"42973",
"120104",
"660",
"115749",
"4553",
"115955",
"111088",
"81675"
],
"user_id": 0,
"object_count": 21
}
]
getIds:
node acc-to-id.js | jq '.' | sponge journeys.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment