-
Notifications
You must be signed in to change notification settings - Fork 31
Add download entire period bundle feature #176
Conversation
pkg/config/config.go
Outdated
@@ -25,6 +25,7 @@ type Constants struct { | |||
HmacKeyLength int | |||
CORSAccessControlAllowOrigin string | |||
DisableCurrentDateCheckFeatureFlag bool | |||
EnableEntirePeriodBundle bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor, and maybe this is just the github editor, but it doesn't line up with the others. Do we have a linter / formatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
dateNumber = endDate | ||
|
||
startTimestamp = time.Unix(int64(startDate*86400), 0) | ||
endTimestamp = time.Unix(int64((endDate+1)*86400), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm reading this wrong, but it seems like we're doing "yesterday" on L77, then taking numberOfDaysToServe in the past, and then on L83 we're adding back the day we removed so we're back to "today"
This seems to imply that we're also serving today as part of the bundle, is there ever a use case where we'd want DisableCurrentDateCheckFeatureFlag to be false and EnableEntirePeriodBundle to be true? It seems like we're assuming that EnableEntirePeriodBundle means DisableCurrentDateCheckFeatureFlag is also true.
It's also entirely possible that my timeMath is just bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endTimestamp is just the outer bound of the period, so you go up to the end days midnight. We need to ensure that yesterdays day is used in startDate
and dateNumber
and that the correct endTimestamp is then calculated.
|
||
currentRSIN := pb.CurrentRollingStartIntervalNumber() | ||
currentDateNumber := timemath.CurrentDateNumber() | ||
|
||
if config.AppConstants.DisableCurrentDateCheckFeatureFlag == false && dateNumber == currentDateNumber { | ||
return s.fail(log(ctx, err), w, "request for current date", "cannot serve data for current period for privacy reasons", http.StatusNotFound) | ||
return s.fail(log(ctx, nil), w, "request for current date", "cannot serve data for current period for privacy reasons", http.StatusNotFound) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, we're checking it here, so we do need both to be true for it to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
active_at = time_in_date('10:00', today_utc.prev_day(8)) | ||
two_days_ago = yesterday_utc.prev_day(1) | ||
|
||
# Our retrieve endpoint returns keys SUBMITTED within the given period. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check the bounds? Like 14 days ago and today as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
This is a feature that will allow a person to download all the key for the period defined by
numberOfDaysToServe
, currently 14, in one package.The access the feature,
enableEntirePeriodBundle
needs to be set totrue
.Instead of the regular day number since unix time, ex:
18440
we use00000
because that is not a valid date but does not require the creation of a new API endpoint or changing the authorization logic behind retrieving bundles. The mobile client can use that as a default before replacing it with the current day.