Skip to content

Commit

Permalink
feat: update time formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Leland Garofalo authored and Leland Garofalo committed Mar 7, 2024
1 parent e2d3f35 commit d05dee8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
24 changes: 12 additions & 12 deletions internal/db/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Service struct {
Fee sql.NullString
ApplicationProcess sql.NullString
ResourceId sql.NullInt32
VerifiedAt sql.NullTime
VerifiedAt *time.Time
Email sql.NullString
Status sql.NullInt32
Certified bool
Expand All @@ -46,7 +46,7 @@ type Service struct {
ContactId sql.NullInt32
FundingId sql.NullInt32
AlternateName sql.NullString
CertifiedAt sql.NullTime
CertifiedAt *time.Time
Featured sql.NullBool
SourceAttribution sql.NullInt32
InternalNote sql.NullString
Expand Down Expand Up @@ -80,29 +80,29 @@ type Address struct {
Name sql.NullString
Description sql.NullString
Transportation sql.NullString
CreatedAt sql.NullTime
UpdatedAt sql.NullTime
CreatedAt time.Time
UpdatedAt time.Time
}
type Eligibility struct {
Id int
Name sql.NullString
FeatureRank sql.NullInt32
CreatedAt sql.NullTime
UpdatedAt sql.NullTime
CreatedAt time.Time
UpdatedAt time.Time
}
type Instruction struct {
Id int
Instruction sql.NullString
CreatedAt sql.NullTime
UpdatedAt sql.NullTime
CreatedAt time.Time
UpdatedAt time.Time
}
type Document struct {
Id int
Name sql.NullString
Url sql.NullString
Description sql.NullString
CreatedAt sql.NullTime
UpdatedAt sql.NullTime
CreatedAt time.Time
UpdatedAt time.Time
}
type Resource struct {
Id int
Expand All @@ -114,9 +114,9 @@ type Resource struct {
Name string
ShortDescription sql.NullString
Status sql.NullString
VerifiedAt sql.NullString
VerifiedAt *time.Time
Website sql.NullString
CertifiedAt sql.NullTime
CertifiedAt *time.Time
Featured sql.NullBool
SourceAttribution sql.NullString
InternalNote sql.NullString
Expand Down
9 changes: 5 additions & 4 deletions internal/resources/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ func FromDBType(dbResource *db.Resource) *Resource {
status := Status(dbResource.Status.String)
resource.Status = &status
}
if dbResource.VerifiedAt.Valid {
resource.VerifiedAt = &dbResource.VerifiedAt.String
if dbResource.VerifiedAt != nil {
verifiedAt := dbResource.VerifiedAt.Format("2006-01-02T15:04:05.000Z")
resource.VerifiedAt = &verifiedAt
}
if dbResource.Website.Valid {
resource.Website = &dbResource.Website.String
}
if dbResource.CertifiedAt.Valid {
certifiedAt := dbResource.CertifiedAt.Time.Format("2006-01-02T15:04:05.000Z07:00")
if dbResource.CertifiedAt != nil {
certifiedAt := dbResource.CertifiedAt.Format("2006-01-02T15:04:05.000Z")
resource.CertifiedAt = &certifiedAt
}
if dbResource.Featured.Valid {
Expand Down
10 changes: 5 additions & 5 deletions internal/services/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func convertServiceToResourceService(dbService *db.Service) *resources.ResourceS
Certified: dbService.Certified,
Id: dbService.Id,
SourceAttribution: SourceAttribution(int(dbService.SourceAttribution.Int32)),
UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00"),
UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z"),
}
if dbService.AlternateName.Valid {
service.AlternateName = &dbService.AlternateName.String
Expand Down Expand Up @@ -140,15 +140,15 @@ func convertServiceToResourceService(dbService *db.Service) *resources.ResourceS
if dbService.Url.Valid {
service.Url = &dbService.Url.String
}
if dbService.VerifiedAt.Valid {
verifiedAt := dbService.VerifiedAt.Time.String()
if dbService.VerifiedAt != nil {
verifiedAt := dbService.VerifiedAt.Format("2006-01-02T15:04:05.000Z")
service.VerifiedAt = &verifiedAt
}
if dbService.WaitTime.Valid {
service.WaitTime = &dbService.WaitTime.String
}
if dbService.CertifiedAt.Valid {
certifiedAt := dbService.CertifiedAt.Time.String()
if dbService.CertifiedAt != nil {
certifiedAt := dbService.CertifiedAt.Format("2006-01-02T15:04:05.000Z")
service.CertifiedAt = &certifiedAt
}
if dbService.Featured.Valid {
Expand Down
10 changes: 5 additions & 5 deletions internal/services/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func FromDBType(dbService *db.Service) *Service {
Certified: dbService.Certified,
Id: dbService.Id,
SourceAttribution: SourceAttribution(int(dbService.SourceAttribution.Int32)),
UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00"),
UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z"),
}
if dbService.AlternateName.Valid {
service.AlternateName = &dbService.AlternateName.String
Expand Down Expand Up @@ -87,15 +87,15 @@ func FromDBType(dbService *db.Service) *Service {
if dbService.Url.Valid {
service.Url = &dbService.Url.String
}
if dbService.VerifiedAt.Valid {
verifiedAt := dbService.VerifiedAt.Time.String()
if dbService.VerifiedAt != nil {
verifiedAt := dbService.VerifiedAt.Format("2006-01-02T15:04:05.000Z")
service.VerifiedAt = &verifiedAt
}
if dbService.WaitTime.Valid {
service.WaitTime = &dbService.WaitTime.String
}
if dbService.CertifiedAt.Valid {
certifiedAt := dbService.CertifiedAt.Time.String()
if dbService.CertifiedAt != nil {
certifiedAt := dbService.CertifiedAt.Format("2006-01-02T15:04:05.000Z")
service.CertifiedAt = &certifiedAt
}
if dbService.Featured.Valid {
Expand Down

0 comments on commit d05dee8

Please sign in to comment.