Skip to content

Commit 666b3c1

Browse files
committed
Replace 47 with SFBayChapterId variable
1 parent d4becf9 commit 666b3c1

File tree

8 files changed

+30
-17
lines changed

8 files changed

+30
-17
lines changed

server/src/form_processor/queries.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package form_processor
22

3+
import "github.com/dxe/adb/model"
4+
35
/* Form application queries */
46
const applicationResponsesToProcessQuery = "SELECT id FROM form_application WHERE processed = 0 and name <> ''"
57

@@ -33,7 +35,7 @@ SET
3335
# mark as processed
3436
form_application.processed = 1
3537
WHERE
36-
chapter_id = 47
38+
chapter_id = ` + model.SFBayChapterIdStr + `
3739
and form_application.id = ?
3840
and form_application.name <> ''
3941
and form_application.processed = 0
@@ -74,7 +76,7 @@ SET
7476
# mark as processed
7577
form_application.processed = 1
7678
WHERE
77-
chapter_id = 47
79+
chapter_id = ` + model.SFBayChapterIdStr + `
7880
and form_application.id = ?
7981
and form_application.name <> ''
8082
and form_application.processed = 0
@@ -189,7 +191,7 @@ select
189191
'',
190192
'',
191193
NULL,
192-
'47',
194+
'` + model.SFBayChapterIdStr + `',
193195
form_application.language,
194196
form_application.accessibility
195197
from
@@ -215,7 +217,7 @@ WHERE
215217
and activists.dev_application_date = cast(form_application.timestamp as date)
216218
and form_application.processed = 0
217219
and activists.hidden < 1
218-
and activists.chapter_id = 47;
220+
and activists.chapter_id = ` + model.SFBayChapterIdStr + `;
219221
`
220222

221223
/* Form interest query */
@@ -247,7 +249,7 @@ SET
247249
form_interest.processed = 1
248250
249251
WHERE
250-
chapter_id = 47
252+
chapter_id = ` + model.SFBayChapterIdStr + `
251253
and form_interest.id = ?
252254
and form_interest.processed = 0
253255
and activists.hidden = 0
@@ -282,7 +284,7 @@ SET
282284
# mark as processed
283285
form_interest.processed = 1
284286
WHERE
285-
chapter_id = 47
287+
chapter_id = ` + model.SFBayChapterIdStr + `
286288
and form_interest.id = ?
287289
AND form_interest.processed = 0
288290
AND activists.hidden = 0
@@ -392,7 +394,7 @@ SELECT
392394
'',
393395
NULL,
394396
IF(LENGTH(form_interest.discord_id),form_interest.discord_id,NULL),
395-
'47'
397+
'` + model.SFBayChapterIdStr + `'
396398
FROM
397399
form_interest
398400
WHERE
@@ -411,11 +413,11 @@ INNER JOIN
411413
SET
412414
form_interest.processed = 1
413415
WHERE
414-
activists.chapter_id = 47
416+
activists.chapter_id = ` + model.SFBayChapterIdStr + `
415417
AND form_interest.id = ?
416418
AND form_interest.processed = 0
417419
AND activists.hidden < 1;
418420
`
419421

420422
/* Common queries */
421-
const countActivistsForEmailQuery = "SELECT count(id) AS amount FROM activists WHERE hidden = 0 and email = ? and chapter_id = 47"
423+
const countActivistsForEmailQuery = "SELECT count(id) AS amount FROM activists WHERE hidden = 0 and email = ? and chapter_id = " + model.SFBayChapterIdStr

server/src/form_processor/testing_queries.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package form_processor
22

3+
import "github.com/dxe/adb/model"
4+
35
/* Common queries */
46
const insertActivistQuery = `
5-
INSERT INTO activists (id, email, name, chapter_id) VALUES (NULL, "email1", ?, 47);
7+
INSERT INTO activists (id, email, name, chapter_id) VALUES (NULL, "email1", ?, ` + model.SFBayChapterIdStr + `);
68
`
79

810
const getActivistsQuery = `SELECT id FROM activists;`

server/src/members/index.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"html/template"
77
"sort"
88
"strings"
9+
10+
"github.com/dxe/adb/model"
911
)
1012

1113
var admins = map[string]bool{
@@ -150,7 +152,7 @@ from (
150152
from events
151153
) e on (e.id = ea.event_id)
152154
where a.email = ?
153-
and a.chapter_id = 47
155+
and a.chapter_id = ` + model.SFBayChapterIdStr + `
154156
and not a.hidden
155157
group by a.id, e.month
156158
) x

server/src/members/reminder.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"html/template"
66
"sort"
77
"time"
8+
9+
"github.com/dxe/adb/model"
810
)
911

1012
func (s *server) reminder() {
@@ -62,7 +64,7 @@ with target as (select ?),
6264
sfbay as (
6365
select *
6466
from activists a
65-
where a.chapter_id = 47
67+
where a.chapter_id = ` + model.SFBayChapterIdStr + `
6668
and a.activist_level in ('Organizer', 'Chapter Member')
6769
and not a.hidden
6870
),

server/src/members/roster.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"strconv"
1212
"strings"
1313
"time"
14+
15+
"github.com/dxe/adb/model"
1416
)
1517

1618
func (s *server) roster() {
@@ -112,7 +114,7 @@ with target as (select ?),
112114
sfbay as (
113115
select *
114116
from activists a
115-
where a.chapter_id = 47
117+
where a.chapter_id = ` + model.SFBayChapterIdStr + `
116118
and a.activist_level in ('Organizer', 'Chapter Member')
117119
and not a.hidden
118120
),

server/src/model/activist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ SELECT
749749
name,
750750
email
751751
FROM activists
752-
WHERE hidden = 0 AND activist_level IN('Organizer', 'Chapter Member') AND chapter_id = 47
752+
WHERE hidden = 0 AND activist_level IN('Organizer', 'Chapter Member') AND chapter_id = ` + SFBayChapterIdStr + `
753753
`
754754

755755
var activists []Activist
@@ -768,7 +768,7 @@ SELECT
768768
name,
769769
email
770770
FROM activists
771-
WHERE hidden = 0 AND activist_level = 'Organizer' AND chapter_id = 47
771+
WHERE hidden = 0 AND activist_level = 'Organizer' AND chapter_id = ` + SFBayChapterIdStr + `
772772
`
773773

774774
var activists []Activist
@@ -1152,7 +1152,7 @@ func UpdateActivistData(db *sqlx.DB, activist ActivistExtra, userEmail string) (
11521152
// if in the Bay Area, add to mailing list if needed
11531153
// TODO: make this work for other chapters too, maybe based on Chapters table mailing list info?
11541154
// or maybe just passing chapter Name or ID to the signup service?
1155-
if origActivist.ChapterID == 47 {
1155+
if origActivist.ChapterID == SFBayChapterId {
11561156
mailingListInfoChanged := activist.Name != origActivist.Name ||
11571157
activist.Email != origActivist.Email ||
11581158
activist.Phone != origActivist.Phone ||

server/src/model/chapters.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ type Organizer struct {
7474

7575
type Organizers []*Organizer
7676

77+
const SFBayChapterId = 47
78+
const SFBayChapterIdStr = "47"
79+
7780
func (o Organizers) Value() (driver.Value, error) {
7881
return json.Marshal(o)
7982
}

server/src/survey_mailer/survey_mailer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func survey(db *sqlx.DB, surveyOptions SurveyOptions) {
112112
SurveySent: "0",
113113
SuppressSurvey: "0",
114114
// TODO: consider not hard-coding this
115-
ChapterID: 47, // SF Bay Area
115+
ChapterID: model.SFBayChapterId,
116116
})
117117
if err != nil {
118118
log.Printf("Failed to get events: %v", err)

0 commit comments

Comments
 (0)