diff --git a/go.mod b/go.mod index b1183d4..9bc8377 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/99designs/gqlgen v0.17.24 - github.com/ClusterCockpit/cc-units v0.3.0 + github.com/ClusterCockpit/cc-units v0.4.0 github.com/Masterminds/squirrel v1.5.3 github.com/go-ldap/ldap/v3 v3.4.4 github.com/go-sql-driver/mysql v1.7.0 diff --git a/go.sum b/go.sum index 2711514..e2a6276 100644 --- a/go.sum +++ b/go.sum @@ -83,6 +83,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/ClusterCockpit/cc-units v0.3.0 h1:JEKgEyvN4GABheKIReW2siDXgpYf2zf4STXV2ip418Y= github.com/ClusterCockpit/cc-units v0.3.0/go.mod h1:3S3PAhAayS3pbgcT4q9Vn9VJw22Op51X0YimtG77zBw= +github.com/ClusterCockpit/cc-units v0.4.0 h1:zP5DOu99GmErW0tCDf0gcLrlWt42RQ9dpoONEOh4cI0= +github.com/ClusterCockpit/cc-units v0.4.0/go.mod h1:3S3PAhAayS3pbgcT4q9Vn9VJw22Op51X0YimtG77zBw= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/squirrel v1.5.3 h1:YPpoceAcxuzIljlr5iWpNKaql7hLeG1KLSrhvdHpkZc= diff --git a/tools/archive-migration/main.go b/tools/archive-migration/main.go index 32671e7..17dcc16 100644 --- a/tools/archive-migration/main.go +++ b/tools/archive-migration/main.go @@ -17,6 +17,7 @@ import ( "github.com/ClusterCockpit/cc-backend/internal/config" "github.com/ClusterCockpit/cc-backend/pkg/log" "github.com/ClusterCockpit/cc-backend/pkg/schema" + ccunits "github.com/ClusterCockpit/cc-units" ) const Version = 1 @@ -37,26 +38,26 @@ func loadJobData(filename string) (*JobData, error) { func ConvertUnitString(us string) schema.Unit { var nu schema.Unit - // if us == "CPI" || - // us == "IPC" || - // us == "load" || - // us == "" { - // nu.Base = us - // return nu - // } - // u := ccunits.NewUnit(us) - // p := u.getPrefix() - // if p.Prefix() != "" { - // prefix := p.Prefix() - // nu.Prefix = &prefix - // } - // m := u.getMeasure() - // d := u.getUnitDenominator() - // if d.Short() != "inval" { - // nu.Base = fmt.Sprintf("%s/%s", m.Short(), d.Short()) - // } else { - // nu.Base = m.Short() - // } + if us == "CPI" || + us == "IPC" || + us == "load" || + us == "" { + nu.Base = us + return nu + } + u := ccunits.NewUnit(us) + p := u.GetPrefix() + if p.Prefix() != "" { + prefix := p.Prefix() + nu.Prefix = prefix + } + m := u.GetMeasure() + d := u.GetUnitDenominator() + if d.Short() != "inval" { + nu.Base = fmt.Sprintf("%s/%s", m.Short(), d.Short()) + } else { + nu.Base = m.Short() + } return nu }