Skip to content

Commit 3b0f920

Browse files
committed
fix(V2): add committed filter and reuse toSnakeCase in reference guards
Address bugbot findings: add `committed: false` to the staging query to prevent double-counting references after commit but before sync cleanup, and replace the local toSnakeCase with the existing export from v2-camel-to-snake.js.
1 parent f121d6a commit 3b0f920

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/utils/v2-reference-guards.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
StagingV2,
2020
} from '../models/v2/index.js';
2121
import { Op } from 'sequelize';
22+
import { toSnakeCase } from './v2-camel-to-snake.js';
2223

2324
const REFERENCE_MAP = {
2425
methodology: [
@@ -55,13 +56,12 @@ const REFERENCE_MAP = {
5556
],
5657
};
5758

58-
const toSnakeCase = (value) => value.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`);
59-
6059
const countStagedReferences = async (table, snakeFkField, recordId) => {
6160
const stagedRows = await StagingV2.findAll({
6261
where: {
6362
table,
6463
action: { [Op.in]: ['INSERT', 'UPDATE'] },
64+
committed: false,
6565
failed_commit: false,
6666
},
6767
raw: true,

0 commit comments

Comments
 (0)