From 1ff02a981d0257cad604555e1beb878cd66757d3 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 7 Dec 2023 19:38:02 +1300 Subject: [PATCH] time from millis --- .../20231128_jellyfish_migration.go | 1 - migrations/20231128_jellyfish_migration/utils/utils.go | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go index 7f637eb9b..4f90051f7 100644 --- a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go +++ b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go @@ -98,7 +98,6 @@ func (m *Migration) RunAndExit() { if m.client != nil { m.client.Disconnect(m.ctx) } - os.Exit(1) } } diff --git a/migrations/20231128_jellyfish_migration/utils/utils.go b/migrations/20231128_jellyfish_migration/utils/utils.go index 1b3376c7d..ec4e7bbb5 100644 --- a/migrations/20231128_jellyfish_migration/utils/utils.go +++ b/migrations/20231128_jellyfish_migration/utils/utils.go @@ -40,12 +40,10 @@ func GetValidatedString(bsonData bson.M, fieldName string) (string, error) { func getValidatedTime(bsonData bson.M, fieldName string) (string, error) { if valRaw, ok := bsonData[fieldName]; !ok { return "", errors.Newf("%s is missing", fieldName) - } else if val, ok := valRaw.(string); !ok { - t, err := time.Parse(types.TimeFormat, val) - if err != nil { - return "", err + } else if ms, ok := valRaw.(int64); !ok { + if t := time.Unix(0, ms*int64(time.Millisecond)); !t.IsZero() { + return t.Format(types.TimeFormat), nil } - return t.Format(types.TimeFormat), nil } log.Printf("invalid data %#v", bsonData) return "", errors.Newf("%s is missing", fieldName)