fix
This commit is contained in:
parent
cc7a1808ec
commit
efe62eb303
1 changed files with 11 additions and 11 deletions
|
@ -365,22 +365,22 @@ export default abstract class Chart<T extends Schema> {
|
||||||
if (v > 0) queryForDay[name] = () => `"${name}" + ${v}`;
|
if (v > 0) queryForDay[name] = () => `"${name}" + ${v}`;
|
||||||
if (v < 0) queryForDay[name] = () => `"${name}" - ${Math.abs(v)}`;
|
if (v < 0) queryForDay[name] = () => `"${name}" - ${Math.abs(v)}`;
|
||||||
} else if (Array.isArray(v) && v.length > 0) { // ユニークインクリメント
|
} else if (Array.isArray(v) && v.length > 0) { // ユニークインクリメント
|
||||||
const name = uniqueTempColumnPrefix + k.replaceAll('.', columnDot);
|
const tempColumnName = uniqueTempColumnPrefix + k.replaceAll('.', columnDot);
|
||||||
// TODO: item が文字列以外の場合も対応
|
|
||||||
// TODO: item をSQLエスケープ
|
// TODO: item をSQLエスケープ
|
||||||
// TODO: 値が重複しないようにしたい
|
const itemsForHour = v.filter(item => !logHour[tempColumnName].includes(item)).map(item => `"${item}"`);
|
||||||
const items = v.map(item => `"${item}"`).join(',');
|
const itemsForDay = v.filter(item => !logDay[tempColumnName].includes(item)).map(item => `"${item}"`);
|
||||||
queryForHour[name] = () => `array_cat("${name}", '{${items}}'::varchar[])`;
|
if (itemsForHour.length > 0) queryForHour[tempColumnName] = () => `array_cat("${tempColumnName}", '{${itemsForHour.join(',')}}'::varchar[])`;
|
||||||
queryForDay[name] = () => `array_cat("${name}", '{${items}}'::varchar[])`;
|
if (itemsForDay.length > 0) queryForDay[tempColumnName] = () => `array_cat("${tempColumnName}", '{${itemsForDay.join(',')}}'::varchar[])`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(this.schema)) {
|
// bake unique count
|
||||||
|
for (const [k, v] of Object.entries(finalDiffs)) {
|
||||||
|
if (this.schema[k].uniqueIncrement) {
|
||||||
const name = columnPrefix + k.replaceAll('.', columnDot);
|
const name = columnPrefix + k.replaceAll('.', columnDot);
|
||||||
if (v.uniqueIncrement) {
|
|
||||||
const tempColumnName = uniqueTempColumnPrefix + k.replaceAll('.', columnDot);
|
const tempColumnName = uniqueTempColumnPrefix + k.replaceAll('.', columnDot);
|
||||||
queryForHour[name] = new Set([...finalDiffs[k], ...logHour[tempColumnName]]).size;
|
queryForHour[name] = new Set([...v, ...logHour[tempColumnName]]).size;
|
||||||
queryForDay[name] = new Set([...finalDiffs[k], ...logDay[tempColumnName]]).size;
|
queryForDay[name] = new Set([...v, ...logDay[tempColumnName]]).size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue