diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-11-03 11:36:11 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-11-03 11:36:11 +0900 |
| commit | 7e5dbb2ba5141c44bf8e0426c32eb5c4b1e41c48 (patch) | |
| tree | b772b1eaa0d42d3b7dee6b128471a733ba0b6c8e /src/chart | |
| parent | Improve admin dashboard (diff) | |
| download | sharkey-7e5dbb2ba5141c44bf8e0426c32eb5c4b1e41c48.tar.gz sharkey-7e5dbb2ba5141c44bf8e0426c32eb5c4b1e41c48.tar.bz2 sharkey-7e5dbb2ba5141c44bf8e0426c32eb5c4b1e41c48.zip | |
Fix bug
Diffstat (limited to 'src/chart')
| -rw-r--r-- | src/chart/index.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/chart/index.ts b/src/chart/index.ts index 491f26ce70..a7521288ea 100644 --- a/src/chart/index.ts +++ b/src/chart/index.ts @@ -230,7 +230,7 @@ export default abstract class Chart<T> { null; // ログ取得 - const logs = await this.collection.find({ + let logs = await this.collection.find({ group: group, span: span, date: { @@ -245,6 +245,27 @@ export default abstract class Chart<T> { } }); + // 要求された範囲にログがひとつもなかったら + if (logs.length == 0) { + // もっとも新しいログを持ってくる + // (すくなくともひとつログが無いと隙間埋めできないため) + const recentLog = await this.collection.findOne({ + group: group, + span: span + }, { + sort: { + date: -1 + }, + fields: { + _id: 0 + } + }); + + if (recentLog) { + logs = [recentLog]; + } + } + // 整形 for (let i = (range - 1); i >= 0; i--) { const current = |