drastically reduce time to create photo folders

This commit is contained in:
Ben Miller
2025-10-19 23:11:22 -06:00
parent a893cd326f
commit 237f57cf36
5 changed files with 99 additions and 44 deletions

View File

@ -22,6 +22,11 @@ export function onEditQueue(e) {
console.log("No SKU found for row " + row)
return
}
// Make sure SKU conforms to expected patterns
if (sku.match(`\\?`) || sku.match(`n$`)) {
console.log("SKU is a placeholder ('?' or 'n...'), skipping batching.")
return
}
// Acquire a user lock to prevent multiple onEdit calls from clashing
const documentLock = LockService.getDocumentLock()
try {
@ -85,6 +90,11 @@ export function processBatchedEdits() {
console.log(
`Processing SKU ${edit.sku}, Timestamp: ${new Date(edit.timestamp)}`
)
// Make sure SKU conforms to expected patterns
if (!edit.sku.match(/^\w+-\d{4}$/)) {
console.log(`SKU ${edit.sku} is not valid, skipping processing.`)
return
}
let p = new Product(edit.sku)
p.UpdateShopifyProduct(shop)
})