Mercurial > gemma
changeset 4283:c811d5da69bd
Use untyped constant and let the compiler do the work.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 29 Aug 2019 17:55:25 +0200 |
parents | 5d6a4dd3efa1 |
children | 4d5cd3b5775a |
files | pkg/imports/fa.go |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/fa.go Thu Aug 29 17:12:03 2019 +0200 +++ b/pkg/imports/fa.go Thu Aug 29 17:55:25 2019 +0200 @@ -41,8 +41,11 @@ const ( // FAJobKind is import queue type identifier. FAJobKind JobKind = "fa" - // Upper limit for days to request - MaxHistoryDays int = 7 +) + +const ( + // maxHistoryDays is the numbers of days to look back. + maxHistoryDays = 7 ) const ( @@ -218,7 +221,7 @@ switch { case err == sql.ErrNoRows: date = pgtype.Timestamp{ - Time: time.Now().AddDate(0, 0, MaxHistoryDays*-1), + Time: time.Now().AddDate(0, 0, -maxHistoryDays), } case err != nil: return pgtype.Timestamp{}, err @@ -228,9 +231,9 @@ // // FIXME: the better solution would be to detect such errors and // dynamically and implement some kind of chunking... - if time.Since(date.Time).Hours() > float64(MaxHistoryDays*24) { + if time.Since(date.Time).Hours() > maxHistoryDays*24 { date = pgtype.Timestamp{ - Time: time.Now().AddDate(0, 0, MaxHistoryDays*-1), + Time: time.Now().AddDate(0, 0, -maxHistoryDays), } }