This repository was archived by the owner on Apr 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocess_bulk_import_results.py
More file actions
89 lines (75 loc) · 3.52 KB
/
process_bulk_import_results.py
File metadata and controls
89 lines (75 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import json
import pprint
import ocldev.oclfleximporter
# Settings
results_filename = 'logs/import_results.json'
# Load results into an OclImportResults object
with open(results_filename) as ifile:
results = json.load(ifile)
import_results = ocldev.oclfleximporter.OclImportResults.load_from_json(results)
# Do this first
print('IMPORT STATS:')
pprint.pprint(import_results.get_stats())
print import_results.get_import_results(
results_mode=ocldev.oclfleximporter.OclImportResults.OCL_IMPORT_RESULTS_MODE_SUMMARY)
# root_key = import_results.get_logging_keys()[0]
results = import_results._results
root_key = results.keys()[0]
pprint.pprint(results[root_key]['NEW']['400'][0])
exit()
count_duplicate_mappings = 0
count_something_else = 0
for result in results[root_key]['NEW']['400']:
if 'errors' in result['message'] and 'must be unique' in result['message']:
count_duplicate_mappings += 1
else:
count_something_else += 1
print result['message']
print 'Duplicate mappings: %s, Other: %s' % (count_duplicate_mappings, count_something_else)
exit()
print import_results.get_import_results(
results_mode=ocldev.oclfleximporter.OclImportResults.OCL_IMPORT_RESULTS_MODE_SUMMARY,
root_key=root_key)
r = import_results.get(root_key)
# print 'update:', r[root_key]['update'].keys()
# print '\t200:', len(r[root_key]['update']['200'])
# print 'new:', r[root_key]['new'].keys()
# print '\t201:', len(r[root_key]['new']['201'])
# print '\t400:', len(r[root_key]['new']['400'])
# managed_from_concept_urls = [
# "/orgs/PEPFAR-Test1/sources/MER-Test1/concepts/EMR_SITE/", # Resolved in gdoc and csv
# "/orgs/PEPFAR-Test1/sources/MER-Test1/concepts/VMMC_TOTALCIRC_NAT/", # Resolved in gdoc and csv
# '/orgs/PEPFAR-Test1/sources/MER-Test1/concepts/HRH_STAFF_NAT/', # No indicator for FY17, but appears to be in the DEs
# "/orgs/PEPFAR-Test1/sources/MER-Test1/concepts/CXCA_TX/", # No indicator for FY17, but appears to be in the DEs
# "/orgs/PEPFAR-Test1/sources/MER-Test1/concepts/CXCA_SCRN/", # No indicator for FY17, but appears to be in the DEs
# ]
managed_from_concept_urls = []
count = 0
for logging_key in r:
for action_type in r[logging_key]:
for status_code in r[logging_key][action_type]:
if status_code not in ['400']:
continue
for result in r[logging_key][action_type][status_code]:
count += 1
if (result['obj_type'] == 'Mapping' and result['message'] == u'{"errors": "from_concept_url : Concept matching query does not exist."}'):
obj = json.loads(result['text'])
if obj['from_concept_url'] not in managed_from_concept_urls:
print '\n**** Found a bad from_concept_url:'
pprint.pprint(result)
pprint.pprint(obj)
print count
exit()
elif (result['obj_type'] == 'Mapping' and result['message'] == u'{"errors": "Parent, map_type, from_concept, to_concept must be unique."}'):
# this is no prob at all, bob
count += 1
else:
print '\n**** Found something else really bad...'
pprint.pprint(result)
print count
exit()
print count
# print import_results.get_detailed_summary()
# print import_results.elapsed_seconds
# print import_results.get_import_results(
# results_mode=ocldev.oclfleximporter.OclImportResults.OCL_IMPORT_RESULTS_MODE_REPORT)