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
subscribe_participants

View file

@ -41,7 +41,7 @@ func main() {
username := flag.String("username", "admin", "Username")
password := flag.String("password", "admin", "Password")
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")
juniorContestId := flag.Int("jid", 0, "Contest ID for Junior category")
@ -82,13 +82,13 @@ func main() {
}
}
}
log.Println(participants)
allParticipants = participants
}
var updated bool
if *unsubscribeAll {
for _, participant := range participants {
for _, participant := range allParticipants {
participant.ContestIDs = make(orm.ContestIDs, 0)
id, err := client.Update(participant)
if err != nil {
@ -124,7 +124,7 @@ func main() {
}
}
for _, participant := range participants {
for _, participant := range allParticipants {
for _, contest := range participant.Contests {
participant.ContestIDs = append(participant.ContestIDs, contest.ID)
}
@ -152,7 +152,7 @@ func main() {
} else {
if *subscribe {
for _, participant := range participants {
for _, participant := range allParticipants {
for _, contest := range participant.Contests {
participant.ContestIDs = append(participant.ContestIDs, contest.ID)
}