Round DSP report values to whole numbers
This commit is contained in:
+3
-3
@@ -241,7 +241,7 @@
|
||||
<button id="nextPage" type="button">下一页</button>
|
||||
</nav>
|
||||
</section>
|
||||
<p class="footnote"><strong>差额规则:</strong>T-1 − T-2 和 T-1 − T-4:≥ +100 显示绿色;≤ −100 显示红色;其余差额显示黑色。页面数据由 AgentStage 每日 10:45(Asia/Shanghai)自动更新。</p>
|
||||
<p class="footnote"><strong>差额规则:</strong>T-1 − T-2 和 T-1 − T-4:≥ +100 显示绿色;≤ −100 显示红色;其余差额显示黑色。页面数据由自动任务每日 10:30(Asia/Shanghai)更新。</p>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
@@ -256,12 +256,12 @@
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
};
|
||||
const numberFormatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
const numberFormatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });
|
||||
const compactFormatter = new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 });
|
||||
const dateFormatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'medium', timeStyle: 'short' });
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const text = (value) => (value === undefined || value === null ? '' : String(value));
|
||||
const money = (value) => numberFormatter.format(Number(value || 0));
|
||||
const money = (value) => numberFormatter.format(Math.round(Number(value || 0)));
|
||||
const shortDate = (date) => date && date.length >= 10 ? date.slice(5).replace('-', '/') : text(date);
|
||||
const svgNode = (name, attributes = {}) => {
|
||||
const node = document.createElementNS('http://www.w3.org/2000/svg', name);
|
||||
|
||||
@@ -59,11 +59,15 @@ def read_response(response) -> str:
|
||||
return response.read().decode("utf-8", errors="replace")
|
||||
|
||||
|
||||
def to_number(value) -> float:
|
||||
def to_number(value) -> int:
|
||||
"""Return a nearest whole number for report metrics."""
|
||||
try:
|
||||
return float(value or 0)
|
||||
number = float(value or 0)
|
||||
except (TypeError, ValueError):
|
||||
return 0.0
|
||||
return 0
|
||||
# Metrics are non-negative in the source; this also handles any negative
|
||||
# values with conventional half-away-from-zero rounding.
|
||||
return int(number + 0.5) if number >= 0 else int(number - 0.5)
|
||||
|
||||
|
||||
def normalise_date(value) -> str:
|
||||
|
||||
Reference in New Issue
Block a user