WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 551ce77

Browse files
committed
split scheduled funcs
1 parent cf561db commit 551ce77

31 files changed

+328
-299
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ routeTree.gen.ts
66
src/blog/tanstack-db-0.1-the-embedded-client-database-for-tanstack-query.md
77
.content-collections
88
.claude
9+
dist/**
10+
.output/**

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

agents/tasks/tanstack-com-task-list.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
### Tasks
2929

3030
- [ ] Implement “Trusted By” on homepage
31+
3132
- Status: Backlog
3233
- Notes:
3334
- Reuse `TrustedByMarquee` but upgrade to support logos + links + tooltip proof.
@@ -42,6 +43,7 @@
4243
- Owner:
4344

4445
- [ ] Add Real-Time Metrics Counters (per-library + org rollup)
46+
4547
- Status: Partial (org rollup live via `OpenSourceStats`)
4648
- Notes:
4749
- Extend counters to per-library pages using existing Convex endpoints or add repo-level endpoints via `convex-oss-stats` if needed.
@@ -89,6 +91,7 @@
8991
### Tasks
9092

9193
- [ ] Redesign/Create “About” page
94+
9295
- Status: Backlog
9396
- Notes:
9497
- Route: `src/routes/about.tsx`.
@@ -98,6 +101,7 @@
98101
- Links: `src/components/MaintainerCard.tsx`, `src/routes/_libraries/maintainers.tsx`.
99102

100103
- [ ] Speaking Engagements section
104+
101105
- Status: Backlog
102106
- Notes:
103107
- Add to About or standalone `src/routes/speaking.tsx`.
@@ -132,6 +136,7 @@
132136
### Tasks
133137

134138
- [ ] “Enterprise” page
139+
135140
- Status: Partial
136141
- Notes:
137142
- Option 1: Rename and expand `paid-support` into `enterprise` (route alias + updated copy) while keeping legacy route.
@@ -160,6 +165,7 @@
160165
### Tasks
161166

162167
- [ ] Public Roadmap page
168+
163169
- Status: Backlog
164170
- Notes:
165171
- Route: `src/routes/roadmap.tsx`.
@@ -188,6 +194,7 @@
188194
### Tasks
189195

190196
- [ ] Press/Media Kit page
197+
191198
- Status: Backlog
192199
- Notes:
193200
- Route: `src/routes/media-kit.tsx`.
@@ -196,6 +203,7 @@
196203
- Acceptance: Page provides direct downloads and usage rules.
197204

198205
- [ ] In the News page
206+
199207
- Status: Backlog
200208
- Notes:
201209
- Route: `src/routes/news.tsx`.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import type { Config } from '@netlify/functions'
2+
import { refreshGitHubOrgStats } from '~/utils/stats.functions'
3+
4+
/**
5+
* Netlify Scheduled Function - Refresh GitHub stats cache
6+
*
7+
* This function refreshes pre-aggregated GitHub stats for the TanStack organization:
8+
* - Organization-level: stars, contributors, dependents, repositories
9+
* - Per-library: stars, contributors, dependents for each library repo
10+
*
11+
* Scheduled: Runs automatically every 6 hours
12+
*
13+
* Performance Impact:
14+
* - Refresh time: ~1-2 minutes for org + all library repos
15+
* - After refresh: ~100-200ms per request (served from cache)
16+
*/
17+
const handler = async (req: Request) => {
18+
const { next_run } = await req.json()
19+
20+
console.log('[refresh-github-stats] Starting GitHub stats refresh...')
21+
22+
const startTime = Date.now()
23+
24+
try {
25+
const org = 'tanstack'
26+
27+
const { orgStats, libraryResults, libraryErrors } =
28+
await refreshGitHubOrgStats(org)
29+
30+
const duration = Date.now() - startTime
31+
console.log(
32+
`[refresh-github-stats] ✓ Completed in ${duration}ms - GitHub Org: ${orgStats.starCount.toLocaleString()} stars, Libraries: ${
33+
libraryResults.length
34+
} refreshed, ${libraryErrors.length} failed`,
35+
)
36+
console.log('[refresh-github-stats] Next invocation at:', next_run)
37+
} catch (error) {
38+
const duration = Date.now() - startTime
39+
const errorMessage = error instanceof Error ? error.message : String(error)
40+
const errorStack = error instanceof Error ? error.stack : undefined
41+
42+
console.error(
43+
`[refresh-github-stats] ✗ Failed after ${duration}ms:`,
44+
errorMessage,
45+
)
46+
if (errorStack) {
47+
console.error('[refresh-github-stats] Stack:', errorStack)
48+
}
49+
}
50+
}
51+
52+
export default handler
53+
54+
export const config: Config = {
55+
schedule: '0 */6 * * *', // Every 6 hours
56+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { Config } from '@netlify/functions'
2+
import { refreshNpmOrgStats } from '~/utils/stats.functions'
3+
4+
/**
5+
* Netlify Scheduled Function - Refresh NPM stats cache
6+
*
7+
* This function refreshes pre-aggregated NPM stats for the TanStack organization:
8+
* - Total downloads across all packages (including legacy packages)
9+
* - Per-package download counts and rates
10+
*
11+
* Scheduled: Runs automatically every 6 hours
12+
* Concurrency: 8 packages at a time, 500ms delay between packages
13+
*
14+
* Performance Impact:
15+
* - Refresh time: ~10-20 minutes for 203 packages (199 scoped + 4 legacy)
16+
* - After refresh: ~100-200ms per request (served from cache)
17+
*/
18+
const handler = async (req: Request) => {
19+
const { next_run } = await req.json()
20+
21+
console.log('[refresh-npm-stats] Starting NPM stats refresh...')
22+
23+
const startTime = Date.now()
24+
25+
try {
26+
const org = 'tanstack'
27+
28+
// Refresh NPM org stats (fetches all packages, aggregates, and caches)
29+
console.log('[refresh-npm-stats] Refreshing NPM org stats...')
30+
const npmStats = await refreshNpmOrgStats(org)
31+
32+
const duration = Date.now() - startTime
33+
console.log(
34+
`[refresh-npm-stats] ✓ Completed in ${duration}ms - NPM: ${npmStats.totalDownloads.toLocaleString()} downloads (${
35+
Object.keys(npmStats.packageStats || {}).length
36+
} packages)`,
37+
)
38+
console.log('[refresh-npm-stats] Next invocation at:', next_run)
39+
} catch (error) {
40+
const duration = Date.now() - startTime
41+
const errorMessage = error instanceof Error ? error.message : String(error)
42+
const errorStack = error instanceof Error ? error.stack : undefined
43+
44+
console.error(
45+
`[refresh-npm-stats] ✗ Failed after ${duration}ms:`,
46+
errorMessage,
47+
)
48+
if (errorStack) {
49+
console.error('[refresh-npm-stats] Stack:', errorStack)
50+
}
51+
}
52+
}
53+
54+
export default handler
55+
56+
export const config: Config = {
57+
schedule: '0 */6 * * *', // Every 6 hours
58+
}

netlify/functions/refresh-stats-cache.ts

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)