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 {
|
type Response struct {
|
||||||
Firstname string
|
Firstname string `csv:"Nome"`
|
||||||
Lastname string
|
Lastname string `csv:"Cognome"`
|
||||||
School string
|
FiscalCode string `csv:"Codice fiscale"`
|
||||||
Region string
|
School string `csv:"Scuola"`
|
||||||
Score int
|
Region string `csv:"Regione"`
|
||||||
Duration uint
|
Score int `csv:"Punteggio"`
|
||||||
|
Duration uint `csv:"Durata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func findAnswer(answers []*orm.Answer, id uint) (*orm.Answer, error) {
|
func findAnswer(answers []*orm.Answer, id uint) (*orm.Answer, error) {
|
||||||
|
@ -118,19 +119,24 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
school, err := findSchool(schools, r.Participant.SchoolID)
|
if r.Score > 0 && r.Duration > 0 {
|
||||||
|
school, err := findSchool(schools, r.Participant.SchoolID)
|
||||||
csvResponses = append(
|
if err != nil {
|
||||||
csvResponses,
|
panic(err)
|
||||||
&Response{
|
}
|
||||||
Firstname: r.Participant.Firstname,
|
csvResponses = append(
|
||||||
Lastname: r.Participant.Lastname,
|
csvResponses,
|
||||||
School: school.String(),
|
&Response{
|
||||||
Region: school.Region.String(),
|
Firstname: r.Participant.Firstname,
|
||||||
Score: r.Score,
|
Lastname: r.Participant.Lastname,
|
||||||
Duration: uint(r.Duration / time.Second),
|
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)
|
f, err := os.Create(*output)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue