fix threshold

This commit is contained in:
2023-07-26 15:32:23 +02:00
parent de685af94a
commit dcb3c445bd

View File

@@ -12,20 +12,22 @@ const props = withDefaults(defineProps<Props>(), {
result: () => []
});
const computedResult = computed(() => props.result.map(r =>({
...r,
buy_ratio: (r.buy_reprocess / r.buy) - 1,
sell_ratio: (r.sell_reprocess / r.sell) - 1
})).sort((a, b) => a.name.localeCompare(b.name)))
const threshold = useStorage('reprocess-threshold', 0);
const threshold = useStorage('reprocess-threshold', 100);
const computedResult = computed(() => {
return props.result.map(r =>({
...r,
buy_ratio: r.buy === 0 ? 1 : (r.buy_reprocess / r.buy) - 1,
sell_ratio: r.sell === 0 ? 1 : (r.sell_reprocess / r.sell) - 1
})).sort((a, b) => a.name.localeCompare(b.name))
})
</script>
<template>
<div class="grid mb-2 mt-4">
<div class="justify-self-end">
<span>Threshold: </span>
<input type="number" min="-100" max="1000" step="1" v-model="threshold" />
<span class="ms-2">Threshold: </span>
<input type="number" min="-100" max="100" step="1" v-model="threshold" />
</div>
</div>
<table>
@@ -39,7 +41,7 @@ const threshold = useStorage('reprocess-threshold', 100);
</tr>
</thead>
<tbody>
<tr v-for="r in computedResult" :key="r.typeID" :class="{'bg-emerald-500': r.buy_ratio * threshold >= 100 }">
<tr v-for="r in computedResult" :key="r.typeID" :class="{'bg-emerald-500': r.buy_ratio >= threshold / 100 }">
<td>{{ r.name }}</td>
<td class="text-right">{{ iskFormater.format(r.buy) }}</td>
<td class="text-right">{{ iskFormater.format(r.buy_reprocess) }} ({{percentFormater.format(r.buy_ratio)}})</td>
@@ -48,4 +50,4 @@ const threshold = useStorage('reprocess-threshold', 100);
</tr>
</tbody>
</table>
</template>@/formaters
</template>