MCPcopy Create free account
hub / github.com/effect-app/libs / factorCaseExpr

Function factorCaseExpr

packages/infra/src/Store/SQL/query.ts:416–420  ·  view source on GitHub ↗
(unitExpr: string, toBase: string, factors: Readonly<Record<string, number>>)

Source from the content-addressed store, hash-verified

414 }
415 }
416 const factorCaseExpr = (unitExpr: string, toBase: string, factors: Readonly<Record<string, number>>) => {
417 const entries = Object.entries(factors).filter(([, factor]) => Number.isFinite(factor))
418 const cases = entries.map(([unit, factor]) => ` WHEN ${sqlStringLiteral(unit)} THEN ${factor}`).join("")
419 return `CASE ${unitExpr} WHEN ${sqlStringLiteral(toBase)} THEN 1${cases} ELSE NULL END`
420 }
421 const filter = "filter" in computed ? computed.filter : []
422 const whereClause = () =>
423 filter.length > 0

Callers 1

computedSelectExprFunction · 0.85

Calls 4

sqlStringLiteralFunction · 0.85
filterMethod · 0.80
joinMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…