def METHOD_NAME(item_type, date):
    # TODO: Check that it gets the correct one from date
    with app.app_context():
        return (
            r.table("usage_consumption")
            .get_all(item_type, index="item_type")
            .filter(r.row["date"] <= date)
            .group("item_id", "item_consumer")
            .max("date")
            .ungroup()
            .map(
                lambda item: [
                    item["group"][0] + "##" + item["group"][1],
                    item["reduction"],
                ]
            )
            .coerce_to("object")
            .run(db.conn)
        )