79685660

Date: 2025-07-01 07:29:17
Score: 1.5
Natty:
Report link

In your function getBodyType I would add the subType to the set before calling the db. If you add to the set in the then clause it will be deferred and processing of the next row may indeed attempt to add the same subType again. You already know that the subTypeis not in the set, so why not add it right away before any other row is processed?

export async function getBodyType(body, conn, map) {
    let subType = body.subType || "Other";

    if (subType && !map.has(subType)) {
        // Insert into the DB as we go, adding it to a set to ensure we don't duplicate
        map.add(subType);
        db.insertBodyType(subType, conn);
    }

    return subType;
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Martin Lisowski