MCPcopy Index your code
hub / github.com/CapSoftware/Cap / getVideoIds

Function getVideoIds

scripts/analytics/populate-test-data.js:136–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134}
135
136async function getVideoIds() {
137 const dbUrl = process.env.DATABASE_URL;
138 if (!dbUrl) {
139 throw new Error("DATABASE_URL environment variable is required");
140 }
141
142 const config = parseDatabaseUrl(dbUrl);
143 const connection = await mysql.createConnection(config);
144
145 try {
146 const [rows] = await connection.execute(
147 "SELECT id, orgId FROM videos LIMIT 1000",
148 );
149
150 const videoIds = rows.map((r) => r.id);
151 const orgMap = new Map();
152 for (const row of rows) {
153 orgMap.set(row.id, row.orgId || "");
154 }
155
156 return { videoIds, orgMap };
157 } finally {
158 await connection.end();
159 }
160}
161
162function distributeViews(videoIds, totalViews) {
163 if (videoIds.length === 0) return [];

Callers 1

mainFunction · 0.85

Calls 1

parseDatabaseUrlFunction · 0.85

Tested by

no test coverage detected