Added api/classifications endpoint, requiring a new query
This commit is contained in:
1 parent
378ac59f41
commit
0e27d2b2f3
9 files changed
+186
-6
No files matched your search
@@ -75,7 +75,9 @@ SELECT t.* FROM opportunities t WHERE t.uuid = ?`
|
||||
|
||||
// ListOpportunities is assembled by listOpportunitiesQuery as:
|
||||
//
|
||||
// listOpportunitiesSelect [WHERE filter AND filter ...] listOpportunitiesOrderAndPage
|
||||
// listOpportunitiesSelect
|
||||
// [WHERE filter AND filter ...]
|
||||
// listOpportunitiesOrderAndPage
|
||||
//
|
||||
// Each filterOpportunity* fragment takes exactly one "?" argument, except
|
||||
// filterOpportunityMark* fragments, which take none. A mark fragment is true
|
||||
@@ -213,6 +215,17 @@ INSERT INTO opportunity_classifications (opportunity_uuid, classification_id)
|
||||
VALUES (?, ?)
|
||||
ON CONFLICT DO NOTHING`
|
||||
|
||||
// selectClassificationsInUse reads every classification code that at least
|
||||
// one opportunity has, once each. c.* must map entirely onto
|
||||
// types.ClassificationCode.
|
||||
const selectClassificationsInUse = `
|
||||
SELECT c.* FROM classification_codes c
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM opportunity_classifications tc
|
||||
WHERE tc.classification_id = c.id
|
||||
)
|
||||
ORDER BY c.code, c.id`
|
||||
|
||||
// selectClassificationsForOpportunities reads the classifications of several
|
||||
// opportunities. "IN (?)" is expanded by sqlx.In, which must be followed by
|
||||
// Rebind. c.* must map entirely onto types.ClassificationCode.
|
||||
|
||||
Reference in new issue
Block a user