Skip to content

Commit b83ba82

Browse files
committed
cut unused testing functions
1 parent 120f0cd commit b83ba82

File tree

1 file changed

+0
-93
lines changed

1 file changed

+0
-93
lines changed

src/db/feedCategories.ts

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ type FeedRiskRow = {
1010
risk_status: string | null
1111
}
1212

13-
type FeedRiskData = {
14-
proxy_address: string
15-
network: string
16-
risk_status: string
17-
}
18-
1913
export type FeedTierResult = { final: string | null }
2014

2115
/* ===========================
@@ -90,59 +84,12 @@ const chooseTier = (dbTier: string | null | undefined, fallback?: string): strin
9084

9185
const defaultCategoryList = () => Object.values(FEED_CATEGORY_CONFIG).map(({ key, name }) => ({ key, name }))
9286

93-
/** Optional convenience for consumers */
94-
export function getCategoryMeta(category?: string | null) {
95-
const key = normalizeKey(category)
96-
return key ? FEED_CATEGORY_CONFIG[key] : undefined
97-
}
98-
9987
/* ===========================
10088
Public API
10189
=========================== */
10290

10391
export const getDefaultCategories = defaultCategoryList
10492

105-
/** Fetch rows (optionally filtered by network). Returns [] on any error. */
106-
export async function getFeedRiskData(network?: string): Promise<FeedRiskData[]> {
107-
if (!supabase) return []
108-
109-
try {
110-
let query = supabase.from(TABLE).select("*")
111-
if (network) query = query.eq("network", network)
112-
113-
const { data, error } = await query.limit(1000)
114-
if (error || !data) return []
115-
116-
// Narrow to non-null risk_status to match FeedRiskData type
117-
return (data as FeedRiskRow[]).filter((r): r is FeedRiskData => !!r.risk_status)
118-
} catch {
119-
return []
120-
}
121-
}
122-
123-
/** Single lookup with fallback-first behavior. */
124-
export async function getFeedRiskTier(
125-
contractAddress: string,
126-
network: string,
127-
fallbackCategory?: string
128-
): Promise<string | null> {
129-
try {
130-
if (!supabase) return chooseTier(null, fallbackCategory)
131-
132-
const { data, error } = await supabase
133-
.from(TABLE)
134-
.select("risk_status")
135-
.eq("proxy_address", contractAddress)
136-
.eq("network", network)
137-
.limit(1)
138-
139-
if (error || !data?.length) return chooseTier(null, fallbackCategory)
140-
return chooseTier(data[0]?.risk_status, fallbackCategory)
141-
} catch {
142-
return chooseTier(null, fallbackCategory)
143-
}
144-
}
145-
14693
/** Merge static categories with those dynamically present in the table. */
14794
export async function getFeedCategories() {
14895
try {
@@ -228,43 +175,3 @@ export async function getFeedRiskTiersBatch(
228175
return out
229176
}
230177
}
231-
232-
/**
233-
* Server-safe helper: uses Supabase on the server; fallback on the client.
234-
*/
235-
export async function getFeedRiskTierWithFallback(
236-
contractAddress: string,
237-
network: string,
238-
fallbackCategory?: string
239-
): Promise<string | undefined> {
240-
try {
241-
if (typeof window === "undefined") {
242-
const riskTier = await getFeedRiskTier(contractAddress, network, fallbackCategory)
243-
return riskTier ?? fallbackCategory
244-
}
245-
return fallbackCategory
246-
} catch {
247-
return fallbackCategory
248-
}
249-
}
250-
251-
/** Lightweight connectivity check. */
252-
export async function testSupabaseConnection() {
253-
try {
254-
if (!supabase) {
255-
return { success: false, data: null, error: "Supabase client not available" }
256-
}
257-
const { data, error } = await supabase.from(TABLE).select("*").limit(1)
258-
return {
259-
success: !error || (error as any)?.code === "PGRST116",
260-
data,
261-
error: (error as any)?.message,
262-
}
263-
} catch (e) {
264-
return {
265-
success: false,
266-
data: null,
267-
error: e instanceof Error ? e.message : "Unknown error",
268-
}
269-
}
270-
}

0 commit comments

Comments
 (0)