-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query non-signers between start and stop times. #464
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,7 +465,8 @@ func (s *server) FetchNonSigners(c *gin.Context) { | |
// @Summary Fetch operators non signing percentage | ||
// @Tags Metrics | ||
// @Produce json | ||
// @Param interval query int false "Interval to query for operators nonsigning percentage [default: 3600]" | ||
// @Param interval query int false "Interval to query for operators nonsigning percentage [default: 3600]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be simpler to just have 2 params: endtime and interval. When endtime is missing, set it to time.Now(). Then it'll be also be backward compatible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems like a good suggestion. I'll go ahead and update. |
||
// @Param end query string false "End time (2006-01-02T15:04:05Z) to query for operators nonsigning percentage [default: now]" | ||
// @Success 200 {object} OperatorsNonsigningPercentage | ||
// @Failure 400 {object} ErrorResponse "error: Bad request" | ||
// @Failure 404 {object} ErrorResponse "error: Not found" | ||
|
@@ -477,11 +478,25 @@ func (s *server) FetchOperatorsNonsigningPercentageHandler(c *gin.Context) { | |
})) | ||
defer timer.ObserveDuration() | ||
|
||
endTime := time.Now() | ||
if c.Query("end") != "" { | ||
|
||
var err error | ||
endTime, err = time.Parse("2006-01-02T15:04:05Z", c.Query("end")) | ||
if err != nil { | ||
errorResponse(c, err) | ||
return | ||
} | ||
} | ||
|
||
interval, err := strconv.ParseInt(c.DefaultQuery("interval", "3600"), 10, 64) | ||
if err != nil || interval == 0 { | ||
interval = 3600 | ||
} | ||
metric, err := s.getOperatorNonsigningRate(c.Request.Context(), interval) | ||
|
||
startTime := endTime.Add(-time.Duration(interval) * time.Second) | ||
|
||
metric, err := s.getOperatorNonsigningRate(c.Request.Context(), startTime.Unix(), endTime.Unix()) | ||
if err != nil { | ||
s.metrics.IncrementFailedRequestNum("FetchOperatorsNonsigningPercentageHandler") | ||
errorResponse(c, err) | ||
|
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.
I'm not sure what happened here. Perhaps I'm using a different version of swaggo?