Repository navigation
feat(status-pages): tables, snapshot contract and daily uptime counters #1927
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e8d5566
feat(status-pages): tables, snapshot contract and daily uptime counters
Makisuo 32e3d74
fix(status-pages): global probe heartbeat, per-entry overlay keys, ed…
Makisuo 3d27981
fix(status-pages): overlay derives component status from its incident…
Makisuo d93c8f4
fix(status-pages): a monitored page with no probe time reads delayed
Makisuo 9b36480
fix(status-pages): regenerate the status pages migration on current main
Makisuo df70471
chore(db): merge the status pages migration with main's migration branch
Makisuo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import * as Orm from "@maple-dev/effect-orm/database" | ||
| import type { MapleDb } from "@maple/db/client" | ||
| import type { OrgId, StatusPageId, UptimeMonitorId } from "@maple/domain/primitives" | ||
| import { Effect } from "effect" | ||
|
|
||
| // The status-page outbox: a write a visitor could see bumps `status_pages.revision` in its own | ||
| // transaction, and the publisher republishes every page whose `published_revision` lags. | ||
|
|
||
| /** Marks one page as needing a publish. */ | ||
| export const bumpPage = (db: MapleDb, orgId: OrgId, pageId: StatusPageId) => | ||
| db.execute( | ||
| Orm.sql`UPDATE status_pages SET revision = revision + 1 WHERE org_id = ${orgId}::text AND id = ${pageId}::text`, | ||
| ) | ||
|
|
||
| /** Marks every page showing one of these monitors (a status flip, a pause, a delete). */ | ||
| export const bumpPagesForMonitors = ( | ||
| db: MapleDb, | ||
| orgId: OrgId, | ||
| monitorIds: ReadonlyArray<UptimeMonitorId>, | ||
| ) => { | ||
| if (monitorIds.length === 0) return Effect.void | ||
| return db.execute(Orm.sql` | ||
| UPDATE status_pages SET revision = revision + 1 | ||
| WHERE org_id = ${orgId}::text AND id IN ( | ||
| SELECT page_id FROM status_page_components | ||
| WHERE org_id = ${orgId}::text AND monitor_id IN (${Orm.sql.join( | ||
| monitorIds.map((id) => Orm.sql`${id}::text`), | ||
| Orm.sql`, `, | ||
| )}) | ||
| )`) | ||
| } | ||
|
|
||
| /** Queues removal of a page's edge data; call in the delete's transaction, before the delete. */ | ||
| export const queuePageRemoval = (db: MapleDb, orgId: OrgId, pageId: StatusPageId) => | ||
| db.execute(Orm.sql` | ||
| INSERT INTO status_page_cleanups (id, org_id, page_id, slug, delete_snapshot, created_at) | ||
| SELECT gen_random_uuid()::text, org_id, id, slug, true, now() | ||
| FROM status_pages WHERE org_id = ${orgId}::text AND id = ${pageId}::text`) | ||
|
|
||
| /** Queues removal of every page of an org, for org deletion. */ | ||
| export const queueOrgPageRemovals = (db: MapleDb, orgId: OrgId) => | ||
| db.execute(Orm.sql` | ||
| INSERT INTO status_page_cleanups (id, org_id, page_id, slug, delete_snapshot, created_at) | ||
| SELECT gen_random_uuid()::text, org_id, id, slug, true, now() | ||
| FROM status_pages WHERE org_id = ${orgId}::text`) | ||
|
|
||
| /** Queues removal of a renamed page's old slug route. */ | ||
| export const queueSlugRemoval = (db: MapleDb, orgId: OrgId, pageId: StatusPageId, slug: string) => | ||
| db.execute(Orm.sql` | ||
| INSERT INTO status_page_cleanups (id, org_id, page_id, slug, delete_snapshot, created_at) | ||
| VALUES (gen_random_uuid()::text, ${orgId}::text, ${pageId}::text, ${slug}::text, false, now())`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.