Skip to content

Commit

Permalink
Initial add reports
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Oct 1, 2024
1 parent 8febd79 commit 6b8bc6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 11 additions & 1 deletion operators/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from openlocationcode import openlocationcode as olc

from srm_tools.stats import Stats
from srm_tools.stats import Report, Stats
from srm_tools.update_table import airtable_updater
from srm_tools.guidestar_api import GuidestarAPI
from srm_tools.budgetkey import fetch_from_budgetkey
Expand Down Expand Up @@ -44,6 +44,14 @@ def fetchEntityFromBudgetKey(regNum):


def updateOrgFromSourceData(ga: GuidestarAPI, stats: Stats):

unknown_entity_ids = Report(
'Entities: Unknown ID Report',
'entities-unknown-id-report',
['id', 'kind'],
['id']
)

def func(rows):
for row in rows:
regNums = [row['id']]
Expand Down Expand Up @@ -83,9 +91,11 @@ def func(rows):
row.update(data['data'])
else:
stats.increase('Entities: Unknown ID')
unknown_entity_ids.add(row)
if 'name' in row:
row['name'] = row['name'].replace(' (חל"צ)', '').replace(' (ע"ר)', '')
yield row
unknown_entity_ids.save()
return func

def recent_org(row):
Expand Down
14 changes: 11 additions & 3 deletions operators/manual_data_entry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import dataflows as DF

from dataflows_airtable import load_from_airtable
from dataflows_airtable import load_from_airtable, AIRTABLE_ID_FIELD

from conf import settings
from srm_tools.logger import logger
from srm_tools.stats import Stats
from srm_tools.stats import Report, Stats
from .mde_utils import load_manual_data
from .external import main as load_external_data

stats = Stats()

def mde_prepare():

unknown_entity_ids = Report(
'Manual Data Entry: No Org ID or Org Name Report',
'manual-data-entry-no-org-id-or-org-name',
['Org Id', 'Org Name', 'Service Name'],
[AIRTABLE_ID_FIELD]
)

source_flow = DF.Flow(
load_from_airtable(settings.AIRTABLE_DATAENTRY_BASE, settings.AIRTABLE_SERVICE_TABLE, settings.AIRTABLE_VIEW, settings.AIRTABLE_API_KEY),
DF.filter_rows(lambda r: r.get('Org Id') != 'dummy'),
stats.filter_with_stat('Manual Data Entry: No Org ID or Org Name', lambda r: (r.get('Org Id') or r.get('Org Name'))),
stats.filter_with_stat('Manual Data Entry: Entry not ready to publish', lambda r: r.get('Status') == 'בייצור'),
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),
)

data_sources = DF.Flow(
Expand Down

0 comments on commit 6b8bc6d

Please sign in to comment.