-
Notifications
You must be signed in to change notification settings - Fork 0
RefreshBadge
Akumetsu edited this page Nov 14, 2022
·
1 revision
The RefreshBadge
operation is an asynchronous operation that refreshes the badge stored in the Supabase bucket with the latest value for the metric.
The operation is called from an AWS SQS queue.
Variable | Required | Description |
---|---|---|
PG_URI |
True |
Postgres Connection Uri: postgresql://<username>:<password>@<host>:<port>/<database>
|
SUPABASE_URL |
True |
Url to the Supabase instance (c.f. Supabase docs) |
SUPABASE_KEY |
True |
Anon Private Key for the Supabase instance |
sequenceDiagram
SQS ->> Entrypoint: {creator, name, metric, params}
Entrypoint ->> RefreshBadgeOperation: {creator, name, metric}
RefreshBadgeOperation ->> ActionRepo: getByCreatorAndName(creator, name)
ActionRepo ->> RefreshBadgeOperation: action
RefreshBadgeOperation ->> BadgeRepo: badgeExists(action.id, metric)
alt BadgeDoesNotExist
rect rgba(150, 0, 0, 0.2)
BadgeRepo ->> RefreshBadgeOperation: False
RefreshBadgeOperation ->> RefreshBadgeOperation: badge = null
RefreshBadgeOperation ->> RefreshBadgeOperation: path = getDefaultStoragePath({creator, name, metric})
end
end
alt BadgeExists
rect rgba(0,150,0,0.2)
BadgeRepo ->> RefreshBadgeOperation: True
RefreshBadgeOperation ->> BadgeRepo: getBadge(action.id, metric)
BadgeRepo ->> RefreshBadgeOperation: badge
RefreshBadgeOperation ->> RefreshBadgeOperation: path = badge.path
end
end
RefreshBadgeOperation ->> MetricRepo: computeMetric(params, actionData)
MetricRepo ->> RefreshBadgeOperation: value
RefreshBadgeOperation ->> RefreshBadgeOperation: label = getBadgeLabel(metric)
RefreshBadgeOperation ->> RefreshBadgeOperation: badgeSvg = generateBadge(label, value)
RefreshBadgeOperation --) BadgeStorageRepo: put(path, badgeSvg)
RefreshBadgeOperation ->> BadgeStorageRepo: getPublicUrl(path)
BadgeStorageRepo ->> RefreshBadgeOperation: uri
alt BadgeDoesNotExist
rect rgba(150, 0, 0, 0.2)
RefreshBadgeOperation --) BadgeRepo: createBadge(newBadgeInformation)
end
end
alt BadgeExists
rect rgba(0, 150, 0, 0.2)
RefreshBadgeOperation --) BadgeRepo: updateBadge(newBadgeInformation)
end
end