Dont write response if duration and score are lesser than zero
This commit is contained in:
parent
7a4f256f7e
commit
fc5ad629a0
2 changed files with 25 additions and 19 deletions
|
@ -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)
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue