-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
5
-
False
-
-
True
-
BIZ-356 - Export of Subscription Watch data
-
-
Given an existing contract with a subscription
When we send an update for the contract, internally we're ending the existing subscription and creating a new one
Then if we call the "/subscriptions/products/
" resource, we'll get only one result as expected because we're merging the ended subscription and the new subscription in the following logic: https://github.com/RedHatInsights/rhsm-subscriptions/blob/main/src/main/java/org/candlepin/subscriptions/resource/SubscriptionTableController.java#L148-L180
However, if we export the same data via the export service, we'll get an duplicated record:
[{'sku': 'MW02393', 'product_name': 'OpenShift Online', 'service_level': 'Premium', 'usage': '', 'org_id': '3340851', 'subscription_number': '1195000', 'quantity': 1.0, 'measurements': []}, <-- this is from the ended subscription {'sku': 'MW02393', 'product_name': 'OpenShift Online', 'service_level': 'Premium', 'usage': '', 'org_id': '3340851', 'subscription_number': '1195000', 'quantity': 1.0, 'measurements': [{'metric_id': 'Cores', 'capacity': 40.0, 'measurement_type': 'PHYSICAL'}, {'metric_id': 'Instance-hours', 'capacity': 12.0, 'measurement_type': 'PHYSICAL'}]}] <-- this is from the new subscription
Note that we can't do the same logic of https://github.com/RedHatInsights/rhsm-subscriptions/blob/main/src/main/java/org/candlepin/subscriptions/resource/SubscriptionTableController.java#L148-L180 in the export service because we need to deal with large data here.
Therefore, as a possible solution to be refined, we should refactor the API to do the same but using a view (similar solution as done for the Instances API).
Acceptance Criteria
- Write IQE test to reproduce/verify the issue
- Both "/subscriptions/products/<product_id>" resource and the export service should return exactly the same data and records.