Skip to content

Commit 6b8bc6d

Browse files
committed
Initial add reports
1 parent 8febd79 commit 6b8bc6d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

operators/entities/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from openlocationcode import openlocationcode as olc
1111

12-
from srm_tools.stats import Stats
12+
from srm_tools.stats import Report, Stats
1313
from srm_tools.update_table import airtable_updater
1414
from srm_tools.guidestar_api import GuidestarAPI
1515
from srm_tools.budgetkey import fetch_from_budgetkey
@@ -44,6 +44,14 @@ def fetchEntityFromBudgetKey(regNum):
4444

4545

4646
def updateOrgFromSourceData(ga: GuidestarAPI, stats: Stats):
47+
48+
unknown_entity_ids = Report(
49+
'Entities: Unknown ID Report',
50+
'entities-unknown-id-report',
51+
['id', 'kind'],
52+
['id']
53+
)
54+
4755
def func(rows):
4856
for row in rows:
4957
regNums = [row['id']]
@@ -83,9 +91,11 @@ def func(rows):
8391
row.update(data['data'])
8492
else:
8593
stats.increase('Entities: Unknown ID')
94+
unknown_entity_ids.add(row)
8695
if 'name' in row:
8796
row['name'] = row['name'].replace(' (חל"צ)', '').replace(' (ע"ר)', '')
8897
yield row
98+
unknown_entity_ids.save()
8999
return func
90100

91101
def recent_org(row):

operators/manual_data_entry/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import dataflows as DF
22

3-
from dataflows_airtable import load_from_airtable
3+
from dataflows_airtable import load_from_airtable, AIRTABLE_ID_FIELD
44

55
from conf import settings
66
from srm_tools.logger import logger
7-
from srm_tools.stats import Stats
7+
from srm_tools.stats import Report, Stats
88
from .mde_utils import load_manual_data
99
from .external import main as load_external_data
1010

1111
stats = Stats()
1212

1313
def mde_prepare():
14+
15+
unknown_entity_ids = Report(
16+
'Manual Data Entry: No Org ID or Org Name Report',
17+
'manual-data-entry-no-org-id-or-org-name',
18+
['Org Id', 'Org Name', 'Service Name'],
19+
[AIRTABLE_ID_FIELD]
20+
)
21+
1422
source_flow = DF.Flow(
1523
load_from_airtable(settings.AIRTABLE_DATAENTRY_BASE, settings.AIRTABLE_SERVICE_TABLE, settings.AIRTABLE_VIEW, settings.AIRTABLE_API_KEY),
1624
DF.filter_rows(lambda r: r.get('Org Id') != 'dummy'),
17-
stats.filter_with_stat('Manual Data Entry: No Org ID or Org Name', lambda r: (r.get('Org Id') or r.get('Org Name'))),
1825
stats.filter_with_stat('Manual Data Entry: Entry not ready to publish', lambda r: r.get('Status') == 'בייצור'),
26+
stats.filter_with_stat('Manual Data Entry: No Org ID or Org Name', lambda r: (r.get('Org Id') or r.get('Org Name')), report=unknown_entity_ids),
1927
)
2028

2129
data_sources = DF.Flow(

0 commit comments

Comments
 (0)