Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions apps/dashboard/src/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
index,
integer,
primaryKey,
sqliteTable,
Expand Down Expand Up @@ -60,46 +59,6 @@ export const verification = sqliteTable("verification", {
updatedAt: integer("updated_at", { mode: "timestamp" }),
});

export const githubResponseCache = sqliteTable(
"github_response_cache",
{
cacheKey: text("cache_key").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
resource: text("resource").notNull(),
paramsJson: text("params_json").notNull(),
etag: text("etag"),
lastModified: text("last_modified"),
payloadJson: text("payload_json").notNull(),
fetchedAt: integer("fetched_at").notNull(),
freshUntil: integer("fresh_until").notNull(),
rateLimitRemaining: integer("rate_limit_remaining"),
rateLimitReset: integer("rate_limit_reset"),
statusCode: integer("status_code").notNull(),
},
(table) => ({
userResourceIdx: index("github_response_cache_user_resource_idx").on(
table.userId,
table.resource,
),
}),
);

export const githubRevalidationSignal = sqliteTable(
"github_revalidation_signal",
{
signalKey: text("signal_key").primaryKey(),
updatedAt: integer("updated_at").notNull(),
},
);

export const githubCacheNamespace = sqliteTable("github_cache_namespace", {
namespaceKey: text("namespace_key").primaryKey(),
version: integer("version").notNull(),
updatedAt: integer("updated_at").notNull(),
});

/**
* Orgs that returned an OAuth App access restriction error during a previous
* search. Used to skip those orgs in the OAuth fallback search source so we
Expand All @@ -120,21 +79,3 @@ export const userForbiddenOrg = sqliteTable(
pk: primaryKey({ columns: [table.userId, table.org] }),
}),
);

export const githubWebhookEvent = sqliteTable(
"github_webhook_event",
{
id: integer("id").primaryKey({ autoIncrement: true }),
deliveryId: text("delivery_id").notNull().unique(),
event: text("event").notNull(),
signalKeysJson: text("signal_keys_json").notNull(),
receivedAt: integer("received_at").notNull(),
processedAt: integer("processed_at"),
errorMessage: text("error_message"),
},
(table) => ({
receivedAtIdx: index("github_webhook_event_received_at_idx").on(
table.receivedAt,
),
}),
);
40 changes: 11 additions & 29 deletions apps/dashboard/src/lib/command-palette/use-refresh-github-data.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
import { toast } from "@diffkit/ui/components/sonner";
import { useCallback, useRef } from "react";
import { clearViewerGitHubCache } from "#/lib/github.functions";
import { useCallback } from "react";
import { GITHUB_QUERY_CACHE_STORAGE_KEY } from "#/lib/query-client";

/**
* Drops the browser's persisted query cache and reloads, so every query
* refetches from GitHub. There is no server-side cache to clear.
*/
export function useRefreshGitHubData() {
const inFlightRef = useRef<Promise<void> | null>(null);

return useCallback(() => {
if (inFlightRef.current) {
return inFlightRef.current;
}

const task = (async () => {
const result = await clearViewerGitHubCache();
if (!result.ok) {
throw new Error("You need to be signed in to refresh data.");
}
toast.loading("Refreshing data…");
try {
window.localStorage.removeItem(GITHUB_QUERY_CACHE_STORAGE_KEY);
window.location.reload();
})();

inFlightRef.current = task
.catch(() => undefined)
.finally(() => {
inFlightRef.current = null;
});

toast.promise(task, {
loading: "Refreshing data…",
error: (error) =>
error instanceof Error ? error.message : "Failed to refresh data",
});

return inFlightRef.current;
} catch {
// Storage can be unavailable (private mode); the reload still refetches.
}
window.location.reload();
}, []);
}
179 changes: 0 additions & 179 deletions apps/dashboard/src/lib/github-cache-invalidation.test.ts

This file was deleted.

Loading
Loading