change delivery count query to show next 7 days instead of current month

This commit is contained in:
Egor Pozharov
2026-04-16 13:00:32 +06:00
parent c373d82135
commit 70129baad5
2 changed files with 6 additions and 2 deletions

View File

@@ -24,7 +24,9 @@ DELETE FROM deliveries WHERE id = $1;
UPDATE deliveries SET date = $1, pickup_location = $2, product_name = $3, address = $4, phone = $5, additional_phone = $6, has_elevator = $7, comment = $8, updated_at = NOW() WHERE id = $9; UPDATE deliveries SET date = $1, pickup_location = $2, product_name = $3, address = $4, phone = $5, additional_phone = $6, has_elevator = $7, comment = $8, updated_at = NOW() WHERE id = $9;
-- name: GetDeliveryCount :many -- name: GetDeliveryCount :many
SELECT COUNT(*) as count, date FROM deliveries WHERE date >= DATE_TRUNC('month', CURRENT_DATE) GROUP BY date; SELECT COUNT(*) as count, date FROM deliveries
WHERE date >= CURRENT_DATE AND date < CURRENT_DATE + INTERVAL '7 days'
GROUP BY date;
-- name: UpdateDeliveryStatus :exec -- name: UpdateDeliveryStatus :exec
UPDATE deliveries SET status = $1, updated_at = NOW() WHERE id = $2; UPDATE deliveries SET status = $1, updated_at = NOW() WHERE id = $2;

View File

@@ -151,7 +151,9 @@ func (q *Queries) GetDeliveryByID(ctx context.Context, id pgtype.UUID) (Delivery
} }
const getDeliveryCount = `-- name: GetDeliveryCount :many const getDeliveryCount = `-- name: GetDeliveryCount :many
SELECT COUNT(*) as count, date FROM deliveries WHERE date >= DATE_TRUNC('month', CURRENT_DATE) GROUP BY date SELECT COUNT(*) as count, date FROM deliveries
WHERE date >= CURRENT_DATE AND date < CURRENT_DATE + INTERVAL '7 days'
GROUP BY date
` `
type GetDeliveryCountRow struct { type GetDeliveryCountRow struct {