Skip to content

Commit 5b73a2d

Browse files
ci: apply automated fixes
1 parent cf561db commit 5b73a2d

File tree

3 files changed

+88
-88
lines changed

3 files changed

+88
-88
lines changed
Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Config } from "@netlify/functions";
1+
import type { Config } from '@netlify/functions'
22
import {
33
refreshNpmOrgStats,
44
fetchGitHubOwnerStats,
55
fetchGitHubRepoStats,
6-
} from "~/utils/stats.functions";
7-
import { setCachedGitHubStats } from "~/utils/stats-db.server";
6+
} from '~/utils/stats.functions'
7+
import { setCachedGitHubStats } from '~/utils/stats-db.server'
88

99
/**
1010
* Netlify Scheduled Function - Refresh org-level stats cache
@@ -21,116 +21,116 @@ import { setCachedGitHubStats } from "~/utils/stats-db.server";
2121
* - After refresh: ~100-200ms per request (served from cache)
2222
*/
2323
const handler = async (req: Request) => {
24-
const { next_run } = await req.json();
24+
const { next_run } = await req.json()
2525

26-
console.log("[refresh-stats-cache-background] Starting stats refresh...");
26+
console.log('[refresh-stats-cache-background] Starting stats refresh...')
2727

28-
const startTime = Date.now();
28+
const startTime = Date.now()
2929

3030
try {
31-
const org = "tanstack";
31+
const org = 'tanstack'
3232

3333
// Refresh NPM org stats (fetches all packages, aggregates, and caches)
34-
console.log("[refresh-stats-cache-background] Refreshing NPM org stats...");
35-
const npmStats = await refreshNpmOrgStats(org);
34+
console.log('[refresh-stats-cache-background] Refreshing NPM org stats...')
35+
const npmStats = await refreshNpmOrgStats(org)
3636

3737
// Refresh GitHub org stats
3838
console.log(
39-
"[refresh-stats-cache-background] Refreshing GitHub org stats..."
40-
);
41-
const githubCacheKey = `org:${org}`;
42-
const githubStats = await fetchGitHubOwnerStats(org);
43-
await setCachedGitHubStats(githubCacheKey, githubStats, 1);
39+
'[refresh-stats-cache-background] Refreshing GitHub org stats...',
40+
)
41+
const githubCacheKey = `org:${org}`
42+
const githubStats = await fetchGitHubOwnerStats(org)
43+
await setCachedGitHubStats(githubCacheKey, githubStats, 1)
4444

4545
// Refresh GitHub stats for each library repo
4646
console.log(
47-
"[refresh-stats-cache-background] Refreshing GitHub stats for individual libraries..."
48-
);
49-
const { libraries } = await import("~/libraries");
47+
'[refresh-stats-cache-background] Refreshing GitHub stats for individual libraries...',
48+
)
49+
const { libraries } = await import('~/libraries')
5050
console.log(
5151
`[refresh-stats-cache-background] Found ${libraries.length} libraries to process:`,
52-
libraries.map((lib) => ({ id: lib.id, repo: lib.repo }))
53-
);
54-
const libraryResults = [];
55-
const libraryErrors = [];
52+
libraries.map((lib) => ({ id: lib.id, repo: lib.repo })),
53+
)
54+
const libraryResults = []
55+
const libraryErrors = []
5656

5757
for (let i = 0; i < libraries.length; i++) {
58-
const library = libraries[i];
58+
const library = libraries[i]
5959
if (!library.repo) {
6060
console.log(
61-
`[refresh-stats-cache-background] Skipping library ${library.id} - no repo`
62-
);
63-
continue;
61+
`[refresh-stats-cache-background] Skipping library ${library.id} - no repo`,
62+
)
63+
continue
6464
}
6565

6666
console.log(
67-
`[refresh-stats-cache-background] Processing library ${library.id} (${library.repo})...`
68-
);
67+
`[refresh-stats-cache-background] Processing library ${library.id} (${library.repo})...`,
68+
)
6969
try {
70-
const repoStats = await fetchGitHubRepoStats(library.repo);
70+
const repoStats = await fetchGitHubRepoStats(library.repo)
7171
console.log(
7272
`[refresh-stats-cache-background] Fetched stats for ${
7373
library.repo
7474
}: ${repoStats.starCount} stars, ${
7575
repoStats.contributorCount
76-
} contributors, ${repoStats.dependentCount ?? "N/A"} dependents`
77-
);
78-
await setCachedGitHubStats(library.repo, repoStats, 1);
76+
} contributors, ${repoStats.dependentCount ?? 'N/A'} dependents`,
77+
)
78+
await setCachedGitHubStats(library.repo, repoStats, 1)
7979
console.log(
80-
`[refresh-stats-cache-background] ✓ Successfully cached stats for ${library.repo}`
81-
);
80+
`[refresh-stats-cache-background] ✓ Successfully cached stats for ${library.repo}`,
81+
)
8282
libraryResults.push({
8383
repo: library.repo,
8484
stars: repoStats.starCount,
85-
});
85+
})
8686

8787
// Add delay between requests to avoid rate limiting (except for last item)
8888
if (i < libraries.length - 1) {
89-
await new Promise((resolve) => setTimeout(resolve, 500));
89+
await new Promise((resolve) => setTimeout(resolve, 500))
9090
}
9191
} catch (error) {
9292
const errorMessage =
93-
error instanceof Error ? error.message : String(error);
93+
error instanceof Error ? error.message : String(error)
9494
console.error(
9595
`[refresh-stats-cache-background] Failed to refresh ${library.repo}:`,
96-
errorMessage
97-
);
96+
errorMessage,
97+
)
9898
libraryErrors.push({
9999
repo: library.repo,
100100
error: errorMessage,
101-
});
101+
})
102102
}
103103
}
104104

105-
const duration = Date.now() - startTime;
105+
const duration = Date.now() - startTime
106106
console.log(
107107
`[refresh-stats-cache-background] ✓ Completed in ${duration}ms - NPM: ${npmStats.totalDownloads.toLocaleString()} downloads (${
108108
Object.keys(npmStats.packageStats || {}).length
109109
} packages), GitHub Org: ${githubStats.starCount.toLocaleString()} stars, Libraries: ${
110110
libraryResults.length
111-
} refreshed, ${libraryErrors.length} failed`
112-
);
111+
} refreshed, ${libraryErrors.length} failed`,
112+
)
113113
console.log(
114-
"[refresh-stats-cache-background] Next invocation at:",
115-
next_run
116-
);
114+
'[refresh-stats-cache-background] Next invocation at:',
115+
next_run,
116+
)
117117
} catch (error) {
118-
const duration = Date.now() - startTime;
119-
const errorMessage = error instanceof Error ? error.message : String(error);
120-
const errorStack = error instanceof Error ? error.stack : undefined;
118+
const duration = Date.now() - startTime
119+
const errorMessage = error instanceof Error ? error.message : String(error)
120+
const errorStack = error instanceof Error ? error.stack : undefined
121121

122122
console.error(
123123
`[refresh-stats-cache-background] ✗ Failed after ${duration}ms:`,
124-
errorMessage
125-
);
124+
errorMessage,
125+
)
126126
if (errorStack) {
127-
console.error("[refresh-stats-cache-background] Stack:", errorStack);
127+
console.error('[refresh-stats-cache-background] Stack:', errorStack)
128128
}
129129
}
130-
};
130+
}
131131

132-
export default handler;
132+
export default handler
133133

134134
export const config: Config = {
135-
schedule: "0 */6 * * *", // Every 6 hours
136-
};
135+
schedule: '0 */6 * * *', // Every 6 hours
136+
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Config } from "@netlify/functions";
2-
import { syncGitHubReleases } from "~/server/feed/github.functions";
1+
import type { Config } from '@netlify/functions'
2+
import { syncGitHubReleases } from '~/server/feed/github.functions'
33

44
/**
55
* Netlify Scheduled Function - Sync GitHub releases
@@ -12,42 +12,42 @@ import { syncGitHubReleases } from "~/server/feed/github.functions";
1212
* Scheduled: Runs automatically every 6 hours
1313
*/
1414
const handler = async (req: Request) => {
15-
const { next_run } = await req.json();
15+
const { next_run } = await req.json()
1616

1717
console.log(
18-
"[sync-github-releases-background] Starting GitHub release sync..."
19-
);
18+
'[sync-github-releases-background] Starting GitHub release sync...',
19+
)
2020

21-
const startTime = Date.now();
21+
const startTime = Date.now()
2222

2323
try {
24-
const result = await syncGitHubReleases();
24+
const result = await syncGitHubReleases()
2525

26-
const duration = Date.now() - startTime;
26+
const duration = Date.now() - startTime
2727
console.log(
28-
`[sync-github-releases-background] ✓ Completed in ${duration}ms - Synced: ${result.syncedCount}, Skipped: ${result.skippedCount}, Errors: ${result.errorCount}`
29-
);
28+
`[sync-github-releases-background] ✓ Completed in ${duration}ms - Synced: ${result.syncedCount}, Skipped: ${result.skippedCount}, Errors: ${result.errorCount}`,
29+
)
3030
console.log(
31-
"[sync-github-releases-background] Next invocation at:",
32-
next_run
33-
);
31+
'[sync-github-releases-background] Next invocation at:',
32+
next_run,
33+
)
3434
} catch (error) {
35-
const duration = Date.now() - startTime;
36-
const errorMessage = error instanceof Error ? error.message : String(error);
37-
const errorStack = error instanceof Error ? error.stack : undefined;
35+
const duration = Date.now() - startTime
36+
const errorMessage = error instanceof Error ? error.message : String(error)
37+
const errorStack = error instanceof Error ? error.stack : undefined
3838

3939
console.error(
4040
`[sync-github-releases-background] ✗ Failed after ${duration}ms:`,
41-
errorMessage
42-
);
41+
errorMessage,
42+
)
4343
if (errorStack) {
44-
console.error("[sync-github-releases-background] Stack:", errorStack);
44+
console.error('[sync-github-releases-background] Stack:', errorStack)
4545
}
4646
}
47-
};
47+
}
4848

49-
export default handler;
49+
export default handler
5050

5151
export const config: Config = {
52-
schedule: "0 */6 * * *", // Every 6 hours
53-
};
52+
schedule: '0 */6 * * *', // Every 6 hours
53+
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import type { Config } from "@netlify/functions";
1+
import type { Config } from '@netlify/functions'
22

33
/**
44
* Netlify Scheduled Function - Test scheduled function
55
*
66
* Scheduled: Runs automatically every minute
77
*/
88
const handler = async (req: Request) => {
9-
const { next_run } = await req.json();
9+
const { next_run } = await req.json()
1010

1111
console.log(
12-
"[test-scheduled-minute] Test message - function executed at:",
13-
new Date().toISOString()
14-
);
15-
console.log("[test-scheduled-minute] Next invocation at:", next_run);
16-
};
12+
'[test-scheduled-minute] Test message - function executed at:',
13+
new Date().toISOString(),
14+
)
15+
console.log('[test-scheduled-minute] Next invocation at:', next_run)
16+
}
1717

18-
export default handler;
18+
export default handler
1919

2020
export const config: Config = {
21-
schedule: "* * * * *", // Every minute
22-
};
21+
schedule: '* * * * *', // Every minute
22+
}

0 commit comments

Comments
 (0)