-
Notifications
You must be signed in to change notification settings - Fork 0
GetBadge
Akumetsu edited this page Nov 14, 2022
·
2 revisions
The GetBadge
operation retrieves an SVG metric badge for the requested action and metric.
The operation verifies if the badge has already been generated and if it is up to date.
If the badge is outdated, then a request is sent to the RefreshBadge
operation to be updated and persisted in the Supabase storage bucket.
Every badge request is logged so that users can track interest in their GitHub Action.
The user can pass the UTM parameters to track where the badge was requested from and the vectors of propagation for the GitHub Action.
Parameter | Value |
---|---|
Prod Endpoint | https://actionstats.app/badge/{creator}/{action name}/{metric} |
Dev Endpoint | https://dev.actionstats.app/badge/{creator}/{action name}/{metric} |
Method | GET |
Target Latency | < 700ms |
Target P95 Latency | < 500ms |
Variable | Required | Description |
---|---|---|
PG_URI |
True |
Postgres Connection Uri: postgresql://<username>:<password>@<host>:<port>/<database>
|
sequenceDiagram
Client ->> Entrypoint: {creator,name,metric}
Entrypoint ->> GetBadgeOperation: {creator,name,metric}
GetBadgeOperation ->> BadgeRepo: getBadge({creator,name}, metric)
alt BadgeDoesNotExist
rect rgba(150,0,0,0.2)
BadgeRepo ->> GetBadgeOperation: Error
GetBadgeOperation ->> MetricsRepo: metricExists(metric)
alt Metric Definition Does Not Exist
rect rgba(200,0,0,.2)
MetricsRepo ->> GetBadgeOperation: False
GetBadgeOperation ->> Entrypoint: Error
Entrypoint ->> Client: 404
end
end
alt Metric Definition Exists
rect rgba(0,200,0,.2)
MetricsRepo ->> GetBadgeOperation: True
GetBadgeOperation ->> ActionRepo: getActionByCreatorAndName(creator, name)
ActionRepo ->> GetBadgeOperation: Action
GetBadgeOperation ->> MetricsRepo: computeMetric(metric, ...args)
MetricsRepo ->> GetBadgeOperation: metric value
GetBadgeOperation ->> BadgeGenerator: generateBadge(badgeConfig, value)
BadgeGenerator ->> GetBadgeOperation: svg
GetBadgeOperation ->> Entrypoint: {raw: svg, outdated: true}
Entrypoint --) Client: 200, svg
Entrypoint --) BadgeWorker: {creator, name, metric}
end
end
end
end
alt BadgeExists
rect rgba(0,150,0,.2)
BadgeRepo ->> GetBadgeOperation: badge
GetBadgeOperation ->> BadgeRepo: isAccurate(actionId, metric)
alt Badge is Not Accurate
rect rgba(200,0,0,.2)
BadgeRepo ->> GetBadgeOperation: false
GetBadgeOperation ->> Entrypoint: {url, outdated: true}
Entrypoint --) Client: {status: 302, uri: badgeUrl}
Entrypoint --) BadgeWorker: {creator, name, metric}
end
end
alt Badge is Accurate
rect rgba(0,200,0,.2)
BadgeRepo ->> GetBadgeOperation: true
GetBadgeOperation ->> Entrypoint: {url, outdated: false}
Entrypoint ->> Client: {status: 302, uri: badgeUrl}
end
end
end
end
Entrypoint --) LogBadgeRequestOperation: {creator, name, metric}