feat: ozon supplies
This commit is contained in:
@@ -150,3 +150,22 @@ def get_users_statistics():
|
|||||||
.all())
|
.all())
|
||||||
result = [{'date': row.date.isoformat(), 'value': row.value, 'order_ids': row.order_ids} for row in query]
|
result = [{'date': row.date.isoformat(), 'value': row.value, 'order_ids': row.order_ids} for row in query]
|
||||||
return jsonify(result)
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
|
@sipro_blueprint.get('/get-orders-by-date')
|
||||||
|
def get_orders_by_date():
|
||||||
|
data: dict = request.args
|
||||||
|
date = datetime.date.fromisoformat(data['date'])
|
||||||
|
query = (
|
||||||
|
database.Assembly.query
|
||||||
|
.filter(
|
||||||
|
func.date_trunc('day', database.Assembly.ended_at) == func.date_trunc('day', date),
|
||||||
|
)
|
||||||
|
.with_entities(
|
||||||
|
func.string_agg(func.cast(database.Assembly.order_id, database.db.String), ',').label('order_ids')
|
||||||
|
)
|
||||||
|
.scalar()
|
||||||
|
)
|
||||||
|
if not query:
|
||||||
|
return jsonify({'order_ids': []})
|
||||||
|
return jsonify({'order_ids': list(map(int, query.split(',')))})
|
||||||
|
|||||||
Reference in New Issue
Block a user