# Path: gogdb/application/datasources.py
# def get_storagedb():
#     if "storagedb" not in flask.g:
#         storage_path = flask.current_app.config["STORAGE_PATH"]
#         flask.g.storagedb = storage.Storage(storage_path)
# 
#     return flask.g.storagedb
# 
# def get_indexdb():
#     if "indexdb" not in flask.g:
#         storagedb = get_storagedb()
#         index_path = storagedb.path_indexdb()
#         flask.g.indexdb = sqlite3.connect(index_path)
#         flask.g.indexdb.row_factory = sqlite3.Row
# 
#     return flask.g.indexdb
# 
# Path: gogdb/core/normalization.py
# def decompress_systems(compressed):
#     systems = []
#     decompress_map = {
#         "w": "windows",
#         "l": "linux",
#         "o": "osx"
#     }
#     for letter in compressed:
#         systems.append(decompress_map[letter])
#     return systems


import copy
import datetime
import itertools
import flask
import gogdb.core.model as model
from gogdb.application.datasources import get_storagedb, get_indexdb
from gogdb.core.normalization import decompress_systems
                history_chart["labels"].append(entry.date.isoformat())
                history_chart["values"].append(str(last_price))
                history_chart["labels"].append(entry.date.isoformat())
                history_chart["values"].append(None)
            last_price = entry.price_final_decimal
    history_chart["max"] = float(history_chart["max"])

    priceframes = []
    for start, end in zip(cur_history[:-1], cur_history[1:]):
        frame = {
            "start": start.date,
            "end": end.date,
            "discount": start.discount,
            "price_final": start.price_final_decimal,
            "price_base": start.price_base_decimal
        }
        priceframes.append(frame)

    # Prefetch referenced products
    referenced_ids = {
        "editions": [edition.id for edition in product.editions],
        "includes_games": product.includes_games,
        "is_included_in": product.is_included_in,
        "required_by": product.required_by,
        "requires": product.requires,
        "dlcs": product.dlcs
    }
    all_references = set(itertools.chain.from_iterable(referenced_ids.values()))
    all_products = {}
    if all_references:

# Path: gogdb/application/datasources.py
# def get_storagedb():
#     if "storagedb" not in flask.g:
#         storage_path = flask.current_app.config["STORAGE_PATH"]
#         flask.g.storagedb = storage.Storage(storage_path)
# 
#     return flask.g.storagedb
# 
# def get_indexdb():
#     if "indexdb" not in flask.g:
#         storagedb = get_storagedb()
#         index_path = storagedb.path_indexdb()
#         flask.g.indexdb = sqlite3.connect(index_path)
#         flask.g.indexdb.row_factory = sqlite3.Row
# 
#     return flask.g.indexdb
# 
# Path: gogdb/core/normalization.py
# def decompress_systems(compressed):
#     systems = []
#     decompress_map = {
#         "w": "windows",
#         "l": "linux",
#         "o": "osx"
#     }
#     for letter in compressed:
#         systems.append(decompress_map[letter])
#     return systems


# Path: gogdb/views/product_info.py
import copy
import datetime
import itertools
import flask
import gogdb.core.model as model
from gogdb.application.datasources import get_storagedb, get_indexdb
from gogdb.core.normalization import decompress_systems

                history_chart["labels"].append(entry.date.isoformat())
                history_chart["values"].append(str(last_price))
                history_chart["labels"].append(entry.date.isoformat())
                history_chart["values"].append(None)
            last_price = entry.price_final_decimal
    history_chart["max"] = float(history_chart["max"])

    priceframes = []
    for start, end in zip(cur_history[:-1], cur_history[1:]):
        frame = {
            "start": start.date,
            "end": end.date,
            "discount": start.discount,
            "price_final": start.price_final_decimal,
            "price_base": start.price_base_decimal
        }
        priceframes.append(frame)

    # Prefetch referenced products
    referenced_ids = {
        "editions": [edition.id for edition in product.editions],
        "includes_games": product.includes_games,
        "is_included_in": product.is_included_in,
        "required_by": product.required_by,
        "requires": product.requires,
        "dlcs": product.dlcs
    }
    all_references = set(itertools.chain.from_iterable(referenced_ids.values()))
    all_products = {}
    if all_references:

        cur = get_indexdb().cursor()