diff --git a/scripts/rank/main.go b/scripts/rank/main.go index 03016e53..2fd11794 100644 --- a/scripts/rank/main.go +++ b/scripts/rank/main.go @@ -15,12 +15,13 @@ import ( ) type Response struct { - Firstname string - Lastname string - School string - Region string - Score int - Duration uint + Firstname string `csv:"Nome"` + Lastname string `csv:"Cognome"` + FiscalCode string `csv:"Codice fiscale"` + School string `csv:"Scuola"` + Region string `csv:"Regione"` + Score int `csv:"Punteggio"` + Duration uint `csv:"Durata"` } func findAnswer(answers []*orm.Answer, id uint) (*orm.Answer, error) { @@ -118,19 +119,24 @@ func main() { panic(err) } - school, err := findSchool(schools, r.Participant.SchoolID) - - csvResponses = append( - csvResponses, - &Response{ - Firstname: r.Participant.Firstname, - Lastname: r.Participant.Lastname, - School: school.String(), - Region: school.Region.String(), - Score: r.Score, - Duration: uint(r.Duration / time.Second), - }, - ) + if r.Score > 0 && r.Duration > 0 { + school, err := findSchool(schools, r.Participant.SchoolID) + if err != nil { + panic(err) + } + csvResponses = append( + csvResponses, + &Response{ + Firstname: r.Participant.Firstname, + Lastname: r.Participant.Lastname, + FiscalCode: r.Participant.FiscalCode, + School: school.String(), + Region: school.Region.String(), + Score: r.Score, + Duration: uint(r.Duration / time.Second), + }, + ) + } } f, err := os.Create(*output) diff --git a/scripts/rank/rank b/scripts/rank/rank deleted file mode 100755 index 136bfc81..00000000 Binary files a/scripts/rank/rank and /dev/null differ