Skip to content

Commit

Permalink
Merge pull request #57 from open-contracting/69-add-unique-item-id-count
Browse files Browse the repository at this point in the history
Aggregates: Add unique item ID count
  • Loading branch information
robredpath committed Oct 7, 2020
2 parents f483d5e + 0cfaa75 commit b01ffe4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.9.0] - 2020-09-07

### Added

- Add Unique IDs count to aggregates
- Added many options to CLI: convert, output-dir, schema-version, delete, exclude-file

### Changed
Expand Down
8 changes: 8 additions & 0 deletions libcoveocds/lib/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_releases_aggregates(json_data):
release_award_item_ids = set()
release_contract_item_ids = set()
item_identifier_schemes = set()
unique_item_ids = set()

unique_currency = set()

Expand Down Expand Up @@ -153,6 +154,8 @@ def get_item_scheme(item):
tender_items = tender.get('items', [])
for item in tender_items:
item_id = item.get('id')
if item_id:
unique_item_ids.add(item_id)
if item_id and release_id:
release_tender_item_ids.add((ocid, release_id, item_id))
get_item_scheme(item)
Expand All @@ -177,6 +180,8 @@ def get_item_scheme(item):
award_items = award.get('items', [])
for item in award_items:
item_id = item.get('id')
if item_id:
unique_item_ids.add(item_id)
if item_id and release_id and award_id:
release_award_item_ids.add((ocid, release_id, award_id, item_id))
get_item_scheme(item)
Expand All @@ -200,6 +205,8 @@ def get_item_scheme(item):
contract_items = contract.get('items', [])
for item in contract_items:
item_id = item.get('id')
if item_id:
unique_item_ids.add(item_id)
if item_id and release_id and contract_id:
release_contract_item_ids.add((ocid, release_id, contract_id, item_id))
get_item_scheme(item)
Expand Down Expand Up @@ -315,6 +322,7 @@ def get_currencies(object):
tender_item_count=len(release_tender_item_ids),
award_item_count=len(release_award_item_ids),
contract_item_count=len(release_contract_item_ids),
unique_item_ids_count=len(unique_item_ids),

item_identifier_schemes=sorted(item_identifier_schemes, key=lambda x: str(x)),
unique_currency=sorted(unique_currency, key=lambda x: str(x)),
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/test_common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'unique_buyers_name_no_id': [],
'unique_currency': [],
'unique_initation_type': [],
'unique_item_ids_count': 0,
'unique_lang': [],
'unique_ocids': [],
'unique_org_count': 0,
Expand Down Expand Up @@ -122,6 +123,7 @@
'unique_buyers_name_no_id': [],
'unique_currency': ['EUR', 'GBP', 'USD', 'YEN'],
'unique_initation_type': ['tender'],
'unique_item_ids_count': 2,
'unique_lang': ['English'],
'unique_ocids': ['1'],
'unique_org_count': 4,
Expand Down Expand Up @@ -175,6 +177,7 @@
'tender_item_count': 770,
'tender_milestones_doc_count': 1163,
'unique_buyers_count': 169,
'unique_item_ids_count': 4698,
'unique_org_count': 1339,
'unique_org_identifier_count': 625,
'unique_org_name_count': 714,
Expand Down

0 comments on commit b01ffe4

Please sign in to comment.