|
43 | 43 | </template>
|
44 | 44 | <template v-if="ratio !== undefined">
|
45 | 45 | <dt
|
46 |
| - class="sm:col-span-4" |
| 46 | + class="text-sm font-medium text-gray-500 sm:col-span-4" |
47 | 47 | v-text="$t('instances.details.cache.hit_ratio')"
|
48 | 48 | />
|
49 |
| - <dd v-text="ratio" /> |
| 49 | + <dd |
| 50 | + class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2" |
| 51 | + v-text="ratio" |
| 52 | + /> |
50 | 53 | </template>
|
51 | 54 | <template v-if="current.size !== undefined">
|
52 | 55 | <dt class="sm:col-span-4" v-text="$t('instances.details.cache.size')" />
|
@@ -91,7 +94,10 @@ export default {
|
91 | 94 | }),
|
92 | 95 | computed: {
|
93 | 96 | ratio() {
|
94 |
| - if (Number.isFinite(this.current.hit) && Number.isFinite(this.current)) { |
| 97 | + if ( |
| 98 | + Number.isFinite(this.current.hit) && |
| 99 | + Number.isFinite(this.current.miss) |
| 100 | + ) { |
95 | 101 | const total = this.current.hit + this.current.miss;
|
96 | 102 | return total > 0
|
97 | 103 | ? ((this.current.hit / total) * 100).toFixed(2) + '%'
|
@@ -179,7 +185,22 @@ export default {
|
179 | 185 | next: (data) => {
|
180 | 186 | this.hasLoaded = true;
|
181 | 187 | this.current = data;
|
182 |
| - this.chartData.push({ ...data, timestamp: moment().valueOf() }); |
| 188 | + let hitsPerInterval = 0; |
| 189 | + let missesPerInterval = 0; |
| 190 | + let totalPerInterval = 0; |
| 191 | + if (this.chartData.length > 0) { |
| 192 | + const lastChartData = this.chartData[this.chartData.length - 1]; |
| 193 | + hitsPerInterval = data.hit - lastChartData.hit; |
| 194 | + missesPerInterval = data.miss - lastChartData.miss; |
| 195 | + totalPerInterval = data.total - lastChartData.total; |
| 196 | + } |
| 197 | + this.chartData.push({ |
| 198 | + ...data, |
| 199 | + timestamp: moment().valueOf(), |
| 200 | + hitsPerInterval, |
| 201 | + missesPerInterval, |
| 202 | + totalPerInterval, |
| 203 | + }); |
183 | 204 | },
|
184 | 205 | error: (error) => {
|
185 | 206 | this.hasLoaded = true;
|
|
0 commit comments