mirror of
https://github.com/System-End/scraps.git
synced 2026-04-19 22:05:09 +00:00
Update airtable-sync.ts
This commit is contained in:
parent
e1a059b66f
commit
5dc1bb5b49
1 changed files with 9 additions and 1 deletions
|
|
@ -133,15 +133,20 @@ async function syncProjectsToAirtable(): Promise<void> {
|
|||
|
||||
// Fetch existing records from Airtable to find which ones to update vs create
|
||||
const existingRecords: Map<string, string> = new Map() // github_url -> airtable record id
|
||||
const approvedRecords: Set<string> = new Set() // github_urls that are already approved in Airtable
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
table.select({
|
||||
fields: ['Code URL']
|
||||
fields: ['Code URL', 'Review Status']
|
||||
}).eachPage(
|
||||
(records, fetchNextPage) => {
|
||||
for (const record of records) {
|
||||
const githubUrl = record.get('Code URL')
|
||||
if (githubUrl) {
|
||||
existingRecords.set(String(githubUrl), record.id)
|
||||
const reviewStatus = record.get('Review Status')
|
||||
if (reviewStatus === 'Approved') {
|
||||
approvedRecords.add(String(githubUrl))
|
||||
}
|
||||
}
|
||||
}
|
||||
fetchNextPage()
|
||||
|
|
@ -167,6 +172,9 @@ async function syncProjectsToAirtable(): Promise<void> {
|
|||
if (!project.githubUrl) continue // skip projects without a GitHub URL
|
||||
if (!project.image) continue // screenshot must exist
|
||||
|
||||
// Skip projects already approved in Airtable — don't overwrite them
|
||||
if (approvedRecords.has(project.githubUrl)) continue
|
||||
|
||||
// Check for duplicate Code URL among shipped projects
|
||||
if (seenCodeUrls.has(project.githubUrl)) {
|
||||
console.log(`[AIRTABLE-SYNC] Duplicate Code URL detected for project ${project.id}: ${project.githubUrl}, reverting to waiting_for_review`)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue