Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Add ExternalIssuers, refactor statistics APIs #1198

Merged
merged 3 commits into from
Nov 26, 2020
Merged

Conversation

sethvargo
Copy link
Member

@sethvargo sethvargo commented Nov 26, 2020

Closes #1159
Fixes #1076

This commit refactors stats and stats APIs to return standardized responses. Instead of munging JSON on the server and the client, the server defines a custom JSON marshaler and the client uses the JSON API to request the chart data. This greatly simplifies the HTML template and controller logic.

In the same vein, there's a custom MarshalCSV interface that all the stats providers implement, and new renderer functions for creating CSVs.

The biggest part of this refactor is the way stats are calculated. Previously stats were naively calculated with a JOIN, but that left zeros or missing data in the structure. The new stats calculation ensures no gaps and fills in zero values where data is missing.

localhost_8080_realm_stats

Release Note

**New statistics API** - Statistics via the JSON API are now returned with more structure and any gaps in dates/users are zeroed to ensure data continuity. 
**External issuers** - When issuing a code via the adminapi, callers can specify an `ExternalIssuerID` to associate the issuance with an external identifier. See the API documentation for more information.

/assign @whaught

@google-cla google-cla bot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Nov 26, 2020
docs/api.md Outdated Show resolved Hide resolved
pkg/controller/realmadmin/show.go Show resolved Hide resolved
pkg/database/external_issuer_stats.go Show resolved Hide resolved
}

type jsonExternalIssuerStatStats struct {
Date time.Time `json:"date"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I'm tired or its my font, but "date" and "data" scan really similarly. I wonder if issuerData would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

jeremyfaller and others added 2 commits November 26, 2020 13:10
This commit refactors stats and stats APIs to return standardized responses. Instead of munging JSON on the server and the client, the server defines a custom JSON marshaler and the client uses the JSON API to request the chart data. This greatly simplifies the HTML template and controller logic.

In the same vein, there's a custom MarshalCSV interface that all the stats providers implement, and new renderer functions for creating CSVs.

The biggest part of this refactor is the way stats are calculated. Previously stats were naively calculated with a JOIN, but that left zeros or missing data in the structure. The new stats calculation ensures no gaps and fills in zero values where data is missing.
@sethvargo
Copy link
Member Author

@whaught fixed up suggestions - PTAL

Copy link
Contributor

@whaught whaught left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit d738454 into main Nov 26, 2020
@google-oss-robot google-oss-robot deleted the sethvargo/pr-1159 branch November 26, 2020 18:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add audit-ID to issue API
4 participants