Skip to content

Commit

Permalink
Add different aggregate identifiers. See #166
Browse files Browse the repository at this point in the history
  • Loading branch information
breyten committed Mar 26, 2024
1 parent 5b80811 commit 39600d7
Showing 1 changed file with 41 additions and 13 deletions.
54 changes: 41 additions & 13 deletions backend/jodal/locations.py
Expand Up @@ -355,20 +355,48 @@ def aggregate(self, items):

def run(self):
items = []
all_item = {
'name': 'Alle gemeenten',
'id': '*',
'kind': 'municipality',
'source': 'cbs',
'sources': []
}
all_items = [
{
'name': 'Alles',
'id': '*',
'kind': 'municipality',
'type': 'Aggregatie',
'source': 'cbs',
'sources': []
},
{
'name': 'Alle gemeenten',
'id': 'type:Gemeente',
'kind': 'municipality',
'type': 'Aggregatie',
'source': 'cbs',
'sources': []
},
{
'name': 'Alle provincies',
'id': 'type:Provincie',
'kind': 'municipality',
'type': 'Aggregatie',
'source': 'cbs',
'sources': []
},
{
'name': 'Alle ministeries',
'id': 'type:Ministerie',
'kind': 'municipality',
'type': 'Aggregatie',
'source': 'cbs',
'sources': []
}
]
for scraper in self.scrapers:
k = scraper()
all_item['sources'].append({
'name': all_item['name'],
'id': all_item['id'],
'source': k.name
})
for a in all_items:
a['sources'].append({
'name': a['name'],
'id': a['id'],
'source': k.name
})
try:
k.items = []
k.run()
Expand All @@ -377,7 +405,7 @@ def run(self):
logging.error(e)
raise e
logging.info('Fetching resulted in %s items ...' % (len(items)))
locations = [all_item] + list(self.aggregate(items))
locations = all_items + list(self.aggregate(items))
es = setup_elasticsearch()
for l in locations:
l['_id'] = l['id']
Expand Down

0 comments on commit 39600d7

Please sign in to comment.