Example #1
0
def add():
    data = request.get_json()
    gtin = data['gtin']
    quantity = data['quantity']
    shop_id = data['shop_id']
    orm = ORM()
    products = orm.get_cache(gtin)
    orm.add_catalog(gtin, quantity, shop_id)
    return jsonify({'quantity': quantity, 'products': products})
Example #2
0
def fill_catalog_table():
    orm = ORM()

    caches = orm.get_caches()
    shops = orm.get_shops()

    for shop in shops:
        for items in range(1, random.randrange(3, 8)):
            for index in range(random.randrange(0, len(caches))):
                gtin = caches[index].get('gtin')
                orm.add_catalog(gtin, random.randint(1, 6), shop.get('id'))
Example #3
0
def barcode_processing():
    data = request.get_json()
    gtin = data['gtin']
    shop_id = data['shop_id']
    product = api.get_product_data(gtin)

    how_much_will_be_waist = ml.predict(product)
    # TODO: Send how_much_will_be_waist to mobile

    orm = ORM()
    products = orm.get_cache(gtin)
    orm.add_catalog(gtin, how_much_will_be_waist, shop_id)
    return jsonify({
        'how_much_will_be_waist': how_much_will_be_waist,
        'products': products
    })