Now participants can be subscribed from CSV file

This commit is contained in:
Andrea Fazzi 2022-05-03 19:56:23 +02:00
parent 2e3324ea8f
commit caf6df59a0
2 changed files with 7 additions and 5 deletions

View file

@ -1 +1,3 @@
*.csv *.csv
subscribe_participants

View file

@ -41,7 +41,7 @@ func main() {
username := flag.String("username", "admin", "Username") username := flag.String("username", "admin", "Username")
password := flag.String("password", "admin", "Password") password := flag.String("password", "admin", "Password")
subscribe := flag.Bool("subscribe", true, "Subscribe to the given contest") subscribe := flag.Bool("subscribe", true, "Subscribe to the given contest")
region := flag.Bool("region", true, "Region based subscription") region := flag.Bool("region", false, "Region based subscription")
unsubscribeAll := flag.Bool("unsubscribe-all", false, "Unsubscribe all participants from all contests") unsubscribeAll := flag.Bool("unsubscribe-all", false, "Unsubscribe all participants from all contests")
juniorContestId := flag.Int("jid", 0, "Contest ID for Junior category") juniorContestId := flag.Int("jid", 0, "Contest ID for Junior category")
@ -82,13 +82,13 @@ func main() {
} }
} }
} }
log.Println(participants) allParticipants = participants
} }
var updated bool var updated bool
if *unsubscribeAll { if *unsubscribeAll {
for _, participant := range participants { for _, participant := range allParticipants {
participant.ContestIDs = make(orm.ContestIDs, 0) participant.ContestIDs = make(orm.ContestIDs, 0)
id, err := client.Update(participant) id, err := client.Update(participant)
if err != nil { if err != nil {
@ -124,7 +124,7 @@ func main() {
} }
} }
for _, participant := range participants { for _, participant := range allParticipants {
for _, contest := range participant.Contests { for _, contest := range participant.Contests {
participant.ContestIDs = append(participant.ContestIDs, contest.ID) participant.ContestIDs = append(participant.ContestIDs, contest.ID)
} }
@ -152,7 +152,7 @@ func main() {
} else { } else {
if *subscribe { if *subscribe {
for _, participant := range participants { for _, participant := range allParticipants {
for _, contest := range participant.Contests { for _, contest := range participant.Contests {
participant.ContestIDs = append(participant.ContestIDs, contest.ID) participant.ContestIDs = append(participant.ContestIDs, contest.ID)
} }