Skip to content

Commit

Permalink
score input float output int (float * 100)
Browse files Browse the repository at this point in the history
  • Loading branch information
rinor committed Oct 15, 2020
1 parent aa66726 commit 4beed79
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions internal/loader/loader.go
Expand Up @@ -32,16 +32,16 @@ func (lvl *Lovelace) UnmarshalCSV(csv string) error {
return nil
}

type Score float32 // (Todo: this will be an int and to be convert to float on the consumer side)
type Score int

// func (sc *Score) UnmarshalCSV(csv string) error {
// f, err := strconv.ParseFloat(csv, 32)
// if err != nil {
// return err
// }
// *sc = Score(f * 100)
// return nil
// }
func (sc *Score) UnmarshalCSV(csv string) error {
f, err := strconv.ParseFloat(csv, 32)
if err != nil {
return err
}
*sc = Score(f * 100)
return nil
}

type ProposalCategory struct {
CategoryID string `json:"category_id" csv:"-"`
Expand Down Expand Up @@ -82,21 +82,6 @@ func (cvo *ChainVoteOptions) MarshalCSV() (string, error) {
return strings.Join(opts, ","), nil
}

/*
type DateTime struct{ time.Time }
// Convert the internal date as CSV string
func (date *DateTime) MarshalCSV() (int64, error) {
return date.Time.Unix(), nil
}
// Convert the CSV string as internal date
func (date *DateTime) UnmarshalCSV(csv string) (err error) {
date.Time, err = time.Parse(time.RFC3339, csv)
return err
}
*/

type ChainVotePlan struct {
VpInternalID string `json:"-" csv:"id"`
VotePlanID string `json:"chain_voteplan_id" csv:"chain_voteplan_id"`
Expand Down

0 comments on commit 4beed79

Please sign in to comment.