Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

chore(api): remove unused request_frequency table code (#2795)

firecrawl-spring[bot]4a72f8c9adec
diff --git a/apps/api/src/controllers/v0/admin/index-queue-prometheus.ts b/apps/api/src/controllers/v0/admin/index-queue-prometheus.ts
index 890d177de..fccaa12b3 100644
--- a/apps/api/src/controllers/v0/admin/index-queue-prometheus.ts
+++ b/apps/api/src/controllers/v0/admin/index-queue-prometheus.ts
@@ -1,7 +1,6 @@
import type { Request, Response } from "express";
import {
getIndexInsertQueueLength,
- getIndexRFInsertQueueLength,
getOMCEQueueLength,
} from "../../../services";
import { getWebhookInsertQueueLength } from "../../../services/webhook";
@@ -9,7 +8,6 @@ import { getWebhookInsertQueueLength } from "../../../services/webhook";
export async function indexQueuePrometheus(req: Request, res: Response) {
const queueLength = await getIndexInsertQueueLength();
const webhookQueueLength = await getWebhookInsertQueueLength();
- const indexRFQueueLength = await getIndexRFInsertQueueLength();
const omceQueueLength = await getOMCEQueueLength();
res.setHeader("Content-Type", "text/plain");
res.send(`\
@@ -17,7 +15,6 @@ export async function indexQueuePrometheus(req: Request, res: Response) {
# TYPE firecrawl_index_queue_length gauge
firecrawl_index_queue_length ${queueLength}
firecrawl_webhook_queue_length ${webhookQueueLength}
-firecrawl_index_rf_queue_length ${indexRFQueueLength}
firecrawl_omce_queue_length ${omceQueueLength}
`);
}
diff --git a/apps/api/src/scraper/scrapeURL/index.ts b/apps/api/src/scraper/scrapeURL/index.ts
index 5e2d90e3d..172ad5eaa 100644
--- a/apps/api/src/scraper/scrapeURL/index.ts
+++ b/apps/api/src/scraper/scrapeURL/index.ts
@@ -54,14 +54,7 @@ import { urlSpecificParams } from "./lib/urlSpecificParams";
import { loadMock, MockState } from "./lib/mock";
import { CostTracking } from "../../lib/cost-tracking";
import { getEngineForUrl } from "../WebScraper/utils/engine-forcing";
-import {
- addIndexRFInsertJob,
- generateDomainSplits,
- hashURL,
- index_supabase_service,
- normalizeURLForIndex,
- useIndex,
-} from "../../services/index";
+import { useIndex } from "../../services/index";
import {
fetchRobotsTxt,
createRobotsChecker,
@@ -978,63 +971,6 @@ export async function scrapeURL(
});
}
- meta.logger.info("Pre-recording frequency");
-
- const shouldRecordFrequency =
- useIndex &&
- meta.options.storeInCache &&
- !meta.internalOptions.zeroDataRetention &&
- internalOptions.teamId !== config.PRECRAWL_TEAM_ID &&
- meta.internalOptions.isPreCrawl !== true; // sitemap crawls override teamId but keep the isPreCrawl flag
- if (shouldRecordFrequency) {
- (async () => {
- try {
- meta.logger.info("Recording frequency");
- const normalizedURL = normalizeURLForIndex(meta.url);
- const urlHash = hashURL(normalizedURL);
-
- let { data, error } = await index_supabase_service
- .from("index")
- .select("id, created_at, status")
- .eq("url_hash", urlHash)
- .order("created_at", { ascending: false })
- .limit(1);
-
- if (error) {
- meta.logger.warn("Failed to get age data", { error });
- }
-
- const age = data?.[0]
- ? Date.now() - new Date(data[0].created_at).getTime()
- : -1;
-
- const fakeDomain = meta.options.__experimental_omceDomain;
- const domainSplits = generateDomainSplits(
- new URL(normalizeURLForIndex(meta.url)).hostname,
- fakeDomain,
- );
- const domainHash = hashURL(domainSplits.slice(-1)[0]);
-
- const out = {
- domain_hash: domainHash,
- url: meta.url,
- age2: age,
- };
-
- await addIndexRFInsertJob(out);
- meta.logger.info("Recorded frequency", { out });
- } catch (error) {
- meta.logger.warn("Failed to record frequency", { error });
- }
- })();
- } else {
- meta.logger.info("Not recording frequency", {
- useIndex,
- storeInCache: meta.options.storeInCache,
- zeroDataRetention: meta.internalOptions.zeroDataRetention,
- });
- }
-
try {
// temporary fix until new scrapeURL system
let documentReattempted = false;
diff --git a/apps/api/src/services/index.ts b/apps/api/src/services/index.ts
index 2f8fc447a..b22cac240 100644
--- a/apps/api/src/services/index.ts
+++ b/apps/api/src/services/index.ts
@@ -362,56 +362,6 @@ export async function getIndexInsertQueueLength(): Promise<number> {
return (await redisEvictConnection.llen(INDEX_INSERT_QUEUE_KEY)) ?? 0;
}
-const INDEX_RF_INSERT_QUEUE_KEY = "index-rf-insert-queue";
-const INDEX_RF_INSERT_BATCH_SIZE = 100;
-
-export async function addIndexRFInsertJob(data: any) {
- await redisEvictConnection.rpush(
- INDEX_RF_INSERT_QUEUE_KEY,
- JSON.stringify(data),
- );
-}
-
-async function getIndexRFInsertJobs(): Promise<any[]> {
- const jobs =
- (await redisEvictConnection.lpop(
- INDEX_RF_INSERT_QUEUE_KEY,
- INDEX_RF_INSERT_BATCH_SIZE,
- )) ?? [];
- return jobs.map(x => JSON.parse(x));
-}
-
-export async function processIndexRFInsertJobs() {
- const jobs = await getIndexRFInsertJobs();
- if (jobs.length === 0) {
- return;
- }
- _logger.info(`Index RF inserter found jobs to insert`, {
- jobCount: jobs.length,
- });
- try {
- const { error } = await index_supabase_service
- .from("request_frequency")
- .insert(jobs);
- if (error) {
- _logger.error(`Index RF inserter failed to insert jobs`, {
- error,
- jobCount: jobs.length,
- });
- }
- _logger.info(`Index RF inserter inserted jobs`, { jobCount: jobs.length });
- } catch (error) {
- _logger.error(`Index RF inserter failed to insert jobs`, {
- error,
- jobCount: jobs.length,
- });
- }
-}
-
-export async function getIndexRFInsertQueueLength(): Promise<number> {
- return (await redisEvictConnection.llen(INDEX_RF_INSERT_QUEUE_KEY)) ?? 0;
-}
-
const OMCE_JOB_QUEUE_KEY = "omce-job-queue";
const OMCE_JOB_QUEUE_BATCH_SIZE = 100;
diff --git a/apps/api/src/services/indexing/index-worker.ts b/apps/api/src/services/indexing/index-worker.ts
index 4561dfc67..e29a3194e 100644
--- a/apps/api/src/services/indexing/index-worker.ts
+++ b/apps/api/src/services/indexing/index-worker.ts
@@ -21,7 +21,6 @@ import { v7 as uuidv7 } from "uuid";
import {
index_supabase_service,
processIndexInsertJobs,
- processIndexRFInsertJobs,
processOMCEJobs,
processDomainFrequencyJobs,
queryDomainsForPrecrawl,
@@ -727,22 +726,6 @@ const DOMAIN_FREQUENCY_INTERVAL = 10000;
await processWebhookInsertJobs();
}, WEBHOOK_INSERT_INTERVAL);
- const indexRFInserterInterval = setInterval(async () => {
- if (isShuttingDown) {
- return;
- }
- await withSpan(
- "firecrawl-index-worker-process-rf-insert-jobs",
- async span => {
- setSpanAttributes(span, {
- "index.worker.operation": "process_rf_insert_jobs",
- "index.worker.type": "scheduled",
- });
- await processIndexRFInsertJobs();
- },
- );
- }, INDEX_INSERT_INTERVAL);
-
const omceInserterInterval = setInterval(async () => {
if (isShuttingDown) {
return;
@@ -828,7 +811,6 @@ const DOMAIN_FREQUENCY_INTERVAL = 10000;
clearInterval(indexInserterInterval);
clearInterval(webhookInserterInterval);
- clearInterval(indexRFInserterInterval);
clearInterval(omceInserterInterval);
clearInterval(domainFrequencyInterval);
clearInterval(billingTallyInterval);