Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-2518

Duplicate records in the Subscriptions Export for contract-based offerings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2024-06-12 - API
    • None
    • None

      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/

      {product_id}

      " 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.

              jcarvaja@redhat.com Jose Carvajal Hilario
              jcarvaja@redhat.com Jose Carvajal Hilario
              Sanket Jagtap Sanket Jagtap
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: