Skip to content

Commit

Permalink
api: fix negative timestamps in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-M authored and jzelinskie committed Feb 24, 2016
1 parent e3a25e5 commit c2061dc
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions api/v1/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,24 @@ func NotificationFromDatabaseModel(dbNotification database.VulnerabilityNotifica
nextPageStr = DBPageNumberToString(nextPage)
}

var created, notified, deleted string
if !dbNotification.Created.IsZero() {
created = fmt.Sprintf("%d", dbNotification.Created.Unix())
}
if !dbNotification.Notified.IsZero() {
notified = fmt.Sprintf("%d", dbNotification.Notified.Unix())
}
if !dbNotification.Deleted.IsZero() {
deleted = fmt.Sprintf("%d", dbNotification.Deleted.Unix())
}

// TODO(jzelinskie): implement "changed" key
fmt.Println(dbNotification.Deleted.IsZero())
return Notification{
Name: dbNotification.Name,
Created: fmt.Sprintf("%d", dbNotification.Created.Unix()),
Notified: fmt.Sprintf("%d", dbNotification.Notified.Unix()),
Deleted: fmt.Sprintf("%d", dbNotification.Deleted.Unix()),
Created: created,
Notified: notified,
Deleted: deleted,
Limit: limit,
Page: DBPageNumberToString(page),
NextPage: nextPageStr,
Expand Down

0 comments on commit c2061dc

Please sign in to comment.