Created
July 10, 2020 18:30
-
-
Save aaronhelton/e7146252299c11b9990d6039964be2d7 to your computer and use it in GitHub Desktop.
This file contains 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
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