19 lines
772 B
SQL
19 lines
772 B
SQL
\echo '=== Aktive Angebotsfassungen (Überblick) ==='
|
|
SELECT ov.offer_id, o.name, ov.number, ov.grant_kind, ov.price_cents
|
|
FROM offer_versions ov
|
|
JOIN offers o ON o.id = ov.offer_id
|
|
WHERE ov.status = 'aktiv'
|
|
ORDER BY ov.offer_id, ov.number;
|
|
|
|
\echo '=== Heutige Registrierungslogik: alle aktiven personen-Registrierungsfassungen ==='
|
|
SELECT count(*)::int AS would_issue_count
|
|
FROM offer_versions
|
|
WHERE status = 'aktiv' AND grant_kind = 'bei_registrierung' AND holder_kind = 'person';
|
|
|
|
\echo '=== Grants je Angebot (über acquisition reference offer) ==='
|
|
SELECT a.reference_id AS offer_id, count(DISTINCT g.id)::int AS grant_count
|
|
FROM acquisitions a
|
|
JOIN grants g ON g.acquisition_id = a.id
|
|
WHERE a.reference_type = 'offer'
|
|
GROUP BY a.reference_id
|
|
ORDER BY a.reference_id; |