Skip to content

Instantly share code, notes, and snippets.

@aaronhelton
Created July 10, 2020 18:30
Show Gist options
  • Save aaronhelton/e7146252299c11b9990d6039964be2d7 to your computer and use it in GitHub Desktop.
Save aaronhelton/e7146252299c11b9990d6039964be2d7 to your computer and use it in GitHub Desktop.
import dlx_dl
import boto3
import re
from pymongo import MongoClient
ssm_client = boto3.client('ssm')
connect_string = ssm_client.get_parameter(Name='connect-string')['Parameter']['Value']
api_key = ssm_client.get_parameter(Name='undl-dhl-metadata-api-key')['Parameter']['Value']
nonce_key = ssm_client.get_parameter(Name='undl-callback-nonce')['Parameter']['Value']
callback_url = ssm_client.get_parameter(Name='undl-callback-url')['Parameter']['Value']
client = MongoClient(connect_string)
result = client['undlFiles']['files'].aggregate([
{
'$match': {
'source': 'adhoc::digitization'
}
},
{
'$project': {
'_id': 0,
'symbol': {
'$arrayElemAt': [
'$identifiers.value', 0
]
}
}
}, {
'$group': {
'_id': {
'symbol': '$symbol'
},
'count': {
'$sum': 1
}
}
}
])
symbols = []
for res in result:
symbol = res["_id"]["symbol"]
symbol_count = client['undlFiles']['bibs'].aggregate([
{
'$match': {
'191.subfields.value': symbol
}
}, {
'$count': 'count'
}
])
for sc in symbol_count:
#print(symbol, sc['count'])
if int(sc['count']) == 0:
print(symbol, sc['count'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment