This reverts commit cdcefda954.
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
# coding=UTF-8
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.utils import lru_with_ttl
|
||||
|
||||
@lru_with_ttl(ttl_seconds=3600)
|
||||
def get_adjustment_config():
|
||||
sql = """
|
||||
select
|
||||
material, product_type, markets.name, price_adjustments.value
|
||||
from
|
||||
price_adjustments
|
||||
join "product-materials" on material_id = materialid
|
||||
join markets on market_id = markets.id
|
||||
"""
|
||||
|
||||
result = db.session.execute(sql)
|
||||
rows = result.fetchall()
|
||||
config = {}
|
||||
for row in rows:
|
||||
[material, product_type, market, value] = row
|
||||
if material not in config:
|
||||
config[material] = {}
|
||||
if product_type not in config[material]:
|
||||
config[material][product_type] = {}
|
||||
config[material][product_type][market] = float(value)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def get_price_adjustment(market, product_type, material):
|
||||
config = get_adjustment_config()
|
||||
|
||||
return config.get(material, {}).get(product_type, {}).get(market, 1.0)
|
||||
Reference in New Issue
Block a user