Skip to content

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

chore(billing): remove the idle credit-usage tally loop (#4010)

firecrawl-spring[bot]d59b65fe70d3
diff --git a/apps/api/src/db/rpc.ts b/apps/api/src/db/rpc.ts
index 02fc53640..96a4ee7b2 100644
--- a/apps/api/src/db/rpc.ts
+++ b/apps/api/src/db/rpc.ts
@@ -138,10 +138,6 @@ export function monitoringClaimDueMonitors<T = Record<string, any>>(params: {
);
}
-export async function updateTallyTeam(i_team_id: string): Promise<void> {
- await db.execute(sql`select update_tally_10_team(i_team_id => ${i_team_id})`);
-}
-
// ============================================================================
// Index database RPCs
// ============================================================================
diff --git a/apps/api/src/services/indexing/index-worker.ts b/apps/api/src/services/indexing/index-worker.ts
index 19c321d4c..3f85f3500 100644
--- a/apps/api/src/services/indexing/index-worker.ts
+++ b/apps/api/src/services/indexing/index-worker.ts
@@ -24,7 +24,7 @@ import {
processOMCEJobs,
queryDomainsForPrecrawl,
} from "..";
-import { queryTopUrlsForDomain, updateTallyTeam } from "../../db/rpc";
+import { queryTopUrlsForDomain } from "../../db/rpc";
import { getSearchIndexClient } from "../../lib/search-index-client";
// Search indexing is now handled by the separate search service
// import { processSearchIndexJobs } from "../../lib/search-index/queue";
@@ -668,41 +668,6 @@ const workerFun = async (
process.exit(0);
};
-async function tallyBilling() {
- const logger = _logger.child({
- module: "index-worker",
- method: "tallyBilling",
- });
- // get up to 100 teams and remove them from set
- const billedTeams = await getRedisConnection().srandmember(
- "billed_teams",
- 100,
- );
-
- if (!billedTeams || billedTeams.length === 0) {
- logger.debug("No billed teams to process");
- return;
- }
-
- await getRedisConnection().srem("billed_teams", billedTeams);
- logger.info("Starting to update tallies", {
- billedTeams: billedTeams.length,
- });
-
- for (const teamId of billedTeams) {
- logger.info("Updating tally for team", { teamId });
-
- try {
- await updateTallyTeam(teamId);
- logger.info("Updated tally for team", { teamId });
- } catch (error) {
- logger.warn("Failed to update tally for team", { teamId, error });
- }
- }
-
- logger.info("Finished updating tallies");
-}
-
const INDEX_INSERT_INTERVAL = 3000;
const WEBHOOK_INSERT_INTERVAL = 15000;
const OMCE_INSERT_INTERVAL = 5000;
@@ -766,16 +731,6 @@ const BROWSER_ACTIVITY_INSERT_INTERVAL = 10000;
});
}, OMCE_INSERT_INTERVAL);
- const billingTallyInterval = setInterval(
- async () => {
- if (isShuttingDown) {
- return;
- }
- await tallyBilling();
- },
- 5 * 60 * 1000,
- );
-
const engpickerPromise = (async () => {
if (config.DISABLE_ENGPICKER) {
logger.info("Engpicker is disabled, skipping");
@@ -824,6 +779,5 @@ const BROWSER_ACTIVITY_INSERT_INTERVAL = 10000;
clearInterval(webhookInserterInterval);
clearInterval(browserActivityInterval);
clearInterval(omceInserterInterval);
- clearInterval(billingTallyInterval);
logger.info("All workers shut down, exiting process");
})();