scan-limits-gating: paid-order gating + per-tag daily cap + per-IP hourly rate (6/6 scenarios) — no gateway
This commit is contained in:
@@ -47,8 +47,8 @@ INSERT INTO tags (tag_code) VALUES ($1)
|
||||
RETURNING *;
|
||||
|
||||
-- name: InsertScan :one
|
||||
INSERT INTO scans (tag_id, lat, lng, location_shared, scanner_phone, fingerprint)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
INSERT INTO scans (tag_id, lat, lng, location_shared, scanner_phone, fingerprint, ip)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetLastAlertByTag :one
|
||||
@@ -74,3 +74,14 @@ SELECT * FROM scans
|
||||
WHERE fingerprint = $1 AND id <> $2 AND scanned_at > now() - interval '24 hours'
|
||||
ORDER BY scanned_at DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetOrderByID :one
|
||||
SELECT * FROM orders WHERE id = $1;
|
||||
|
||||
-- name: CountAlertsByTagSince :one
|
||||
SELECT count(*) FROM scans
|
||||
WHERE tag_id = $1 AND alert_sent = TRUE AND scanned_at > $2;
|
||||
|
||||
-- name: CountAlertsByIPSince :one
|
||||
SELECT count(*) FROM scans
|
||||
WHERE ip = $1 AND alert_sent = TRUE AND scanned_at > $2;
|
||||
|
||||
Reference in New Issue
Block a user