drastically reduce time to create photo folders
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { Product } from "./Product"
|
||||
import { getColumnValuesByName, toastAndLog } from "./sheetUtils"
|
||||
import { createPhotoFolderForSku } from "./Product"
|
||||
import { getColumnRichTextByName, getColumnValuesByName, toastAndLog } from "./sheetUtils"
|
||||
import { Config } from "./config"
|
||||
|
||||
export function createMissingPhotoFolders() {
|
||||
const ss = SpreadsheetApp.getActive()
|
||||
@ -10,14 +11,22 @@ export function createMissingPhotoFolders() {
|
||||
}
|
||||
|
||||
let skus = getColumnValuesByName(s, "sku")
|
||||
let photos = getColumnRichTextByName(s, "photos")
|
||||
let config = new Config()
|
||||
|
||||
for (let i = 0; i < skus.length; i++) {
|
||||
// Process rows backward, as that is where the missing folders are most likely to occur
|
||||
for (let i = skus.length - 1; i >= 0; i--) {
|
||||
const sku = String(skus[i][0])
|
||||
if (!sku) {
|
||||
continue
|
||||
}
|
||||
const product = new Product(sku)
|
||||
product.CreatePhotoFolder()
|
||||
let folderUrl = photos[i][0].getLinkUrl()
|
||||
if (folderUrl && folderUrl.includes("drive.google.com")) {
|
||||
console.log(`Photo folder already exists for SKU: ${sku}`)
|
||||
continue
|
||||
}
|
||||
|
||||
createPhotoFolderForSku(config, sku)
|
||||
}
|
||||
toastAndLog("Finished creating missing photo folders.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user