Skip to content

Commit

Permalink
Fix syndication
Browse files Browse the repository at this point in the history
  • Loading branch information
marcserrat committed Apr 7, 2022
1 parent 0154353 commit aadccc6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
7 changes: 0 additions & 7 deletions reports.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@
"name":"Report period",
"description":"Provide the time period to create the report",
"required":true
},
{
"id":"mkp",
"type":"marketplace",
"name":"Marketplaces",
"required":true,
"description":"Select the marketplaces you want to include in report"
}
]
},
Expand Down
22 changes: 16 additions & 6 deletions reports/ms_products/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def generate(
renderer_type=None,
extra_context_callback=None,
):

limit = client.default_limit
client.default_limit = 100
populate_ta_cache(parameters, client)
client.default_limit = limit
init_tc_cache()
#limit = client.default_limit
#client.default_limit = 100
# populate_ta_cache(parameters, client)
#client.default_limit = limit
subscriptions_rql = R()

if parameters.get("date"):
Expand Down Expand Up @@ -315,9 +315,19 @@ def get_product_specifics(request, client):
"microsoft_plan_subscription_id",
)
values["microsoft_order_id"] = order_id
values["microsoft_tier1_mpn"] = TC_CACHE[request['asset']['product']['id']][request['asset']['tiers']['tier1']['id']]
values["microsoft_tier1_mpn"] = get_param_mpn(request, client)
return values

def init_tc_cache():
for product in PRODUCTS:
TC_CACHE[product] = {}

def get_param_mpn(request, client):
if request['asset']['tiers']['tier1']['id'] in TC_CACHE[request['asset']['product']['id']]:
return TC_CACHE[request['asset']['product']['id']][request['asset']['tiers']['tier1']['id']]
mpn = get_ta_parameter(request, 'tier1', 'tier1_mpn', client)
TC_CACHE[request['asset']['product']['id']][request['asset']['tiers']['tier1']['id']] = mpn
return mpn

def populate_ta_cache(parameters, client):
rql = R()
Expand Down
3 changes: 2 additions & 1 deletion reports/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def get_asset_parameter(asset, param_id):
def get_ta_parameter(request, tier, param_id, client):
try:
rql = R().configuration.account.id.eq(request['asset']['tiers'][tier]['id'])
rql = rql & R().status.eq('approved')
rql &= R().status.eq('approved')
rql &= R().product.id.eq(request['asset']['product']['id'])
tc = client.ns('tier').collection("config-requests").filter(rql).order_by('-created').first()
if 'params' not in tc:
return "-"
Expand Down

0 comments on commit aadccc6

Please sign in to comment.