• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 13906280510

17 Mar 2025 05:45PM UTC coverage: 43.545% (-1.3%) from 44.812%
13906280510

push

github

web-flow
Merge pull request #11422 from hicommonwealth/tim/quest-tweets-poller

Twitter Award XP + Config updates

1368 of 3498 branches covered (39.11%)

Branch coverage included in aggregate %.

12 of 177 new or added lines in 11 files covered. (6.78%)

2582 of 5573 relevant lines covered (46.33%)

36.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/model/src/utils/pgMultiRowUpdate.ts
1
import { QueryTypes, Transaction } from 'sequelize';
2
import { models } from '../database';
3

4
export async function pgMultiRowUpdate(
5
  tableName: string,
6
  columns: {
7
    setColumn: string;
8
    rows: { newValue: string | number; whenCaseValue: string | number }[];
9
  }[],
10
  caseColumn: string,
11
  transaction?: Transaction,
12
) {
NEW
13
  if (columns.length === 0) return false;
×
14

NEW
15
  let updates = ``;
×
NEW
16
  for (const { setColumn, rows } of columns) {
×
NEW
17
    if (updates.length > 0) updates += `, \n`;
×
NEW
18
    updates += `${setColumn} = CASE \n${rows
×
19
      .map(
20
        ({ whenCaseValue, newValue }) =>
NEW
21
          `WHEN ${caseColumn} = ${whenCaseValue} THEN ${newValue}`,
×
22
      )
23
      .join('\n')}`;
NEW
24
    updates += ` \nEND`;
×
25
  }
26

NEW
27
  const caseValues = new Set(
×
NEW
28
    columns.map((c) => c.rows.map((r) => r.whenCaseValue)).flat(),
×
29
  );
NEW
30
  const query = `
×
31
      UPDATE "${tableName}"
32
      SET ${updates}
33
      WHERE ${caseColumn} IN (${Array.from(caseValues).join(', ')});
34
  `;
35

NEW
36
  await models.sequelize.query(query, { transaction, type: QueryTypes.UPDATE });
×
NEW
37
  return true;
×
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc