From c57f472caf2c3658d75803aa9c48eef0040ef236 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 21 Oct 2018 14:47:44 +0900 Subject: [PATCH] Improve readability --- src/services/stats.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/services/stats.ts b/src/services/stats.ts index d5c6916a5..11d5b3dd7 100644 --- a/src/services/stats.ts +++ b/src/services/stats.ts @@ -159,8 +159,14 @@ abstract class Chart { protected commit(query: Obj, group?: Obj, uniqueKey?: string, uniqueValue?: string): void { const update = (stats: ChartDocument) => { // ユニークインクリメントの場合、指定のキーに指定の値が既に存在していたら弾く - if (uniqueKey && stats.unique && stats.unique[uniqueKey] && stats.unique[uniqueKey].includes(uniqueValue)) return; + if ( + uniqueKey && + stats.unique && + stats.unique[uniqueKey] && + stats.unique[uniqueKey].includes(uniqueValue) + ) return; + // ユニークインクリメントの指定のキーに値を追加 if (uniqueKey) { query['$push'] = { [`unique.${uniqueKey}`]: uniqueValue @@ -241,21 +247,21 @@ abstract class Chart { /** * [{ - * x: 1, - * y: 5 + * xxxxx: 1, + * yyyyy: 5 * }, { - * x: 2, - * y: 6 + * xxxxx: 2, + * yyyyy: 6 * }, { - * x: 3, - * y: 7 + * xxxxx: 3, + * yyyyy: 7 * }] * * を * * { - * x: [1, 2, 3], - * y: [5, 6, 7] + * xxxxx: [1, 2, 3], + * yyyyy: [5, 6, 7] * } * * にする