Skip to content

Latest commit

 

History

History
84 lines (74 loc) · 4.13 KB

workflow.md

File metadata and controls

84 lines (74 loc) · 4.13 KB
2024-07-05: first commit

2024-07-10: revise list organization to enhance readability
  1. callhandler

  2. call fetchHandler

    • call fetchFlyerList
      • return flyer list, throw error if failed
    • for each flyer, call fetchProductDetailsHandler
      • call extractProductCodeList
        • return all product code list extracted from flyer
      • call fetchProductDetailsList
        • return product details of the all product from product code list
      • return product details list / null
      • return null if caught error
    • push flyer to new filtered flyer list and assign fetched product details list to flyer only if the fetched product details list is not null / empty
    • throw error if all fetched product list are null / empty
    • throw error if caught error
    • return filtered flyer list each with list of product details
  3. for each fetched flyer call parseAndUpdate

    • database connection : Avien MySQL DataBase with Drizzle ORM using db
    • call parseFlyer
      • return parsed flyer data / null
    • return false if failed to parse flyer as no information for further action
    • call processFlyer
      • call getFlyerID
        • return exsiting flyerID / null
      • return exsiting flyerID and isNew = false if existed flyer
      • call addFlyer
        • return new flyer id / null
      • return exsiting flyerID and isNew = false
      • return null and isNew = false if caught error
    • return false if fail to process flyer
    • call processFlyerStore
      • call getStoreID
        • return if store is not in database
      • otherwise, call addFlyerStore
        • no return as all operations done by Drizzle ORM
    • return false if flyer already existed (isNew = false)
    • for each productdetail object from the flyer's productDetailsList call parseAndUpdateProduct
      • call parseProduct
        • return parsed product data or return null if caught error
      • call parsePriceHistory
        • return parsed price data or return null if caught error
      • call parsePointHistory
        • return parsed point data or return null if caught error
      • return false if fail to parse product
      • call processProduct
        • call getProductID
          • return exsiting product ID / null
        • return exsiting product ID if existed product
        • call addProduct
          • call handleImage
            • return uploaded image url (host by cloundinary)
          • return new product id / null
        • return new product id / null
      • return false if fail to process product
      • call processPriceHistory if price data successfully parsed
        • call getPriceHistoryID
          • return exsiting price ID / null
        • return exsiting price ID if existed price record
        • call addPriceHistory
          • return new price id / null
        • return new price id / null
      • call processPointHistory if price data successfully parsed
        • call getPointHistoryID
          • return exsiting point ID / null
        • return exsiting point ID if existed point record
        • call addPointHistory
          • return new point id / null
        • return new point id / null
      • return true or return false if caught error
    • return false if all fail to parse and update product
    • return true or return false if caught error
  4. throw error if all flyers are fail to parse and update product

  5. catch and throw error