调整导出 CSV 格式,移除 recordId 和 timestamp,时间单位改为毫秒;优化图表显示逻辑,默认隐藏原始和滤波码值
This commit is contained in:
@@ -48,20 +48,21 @@ export async function POST(req: NextRequest) {
|
||||
})
|
||||
}
|
||||
|
||||
// CSV
|
||||
let csv = 'recordId,timestamp,index,timeSec,code,force\n'
|
||||
// CSV(去掉 recordId、timestamp,timeSec 改为毫秒单位)
|
||||
let csv = 'index,timeMs,code,force\n'
|
||||
for (const r of rows) {
|
||||
let step = r.sample_count > 0 ? r.duration / r.sample_count : 0
|
||||
// 以毫秒为单位的步长
|
||||
let stepMs = r.sample_count > 0 ? (r.duration * 1000) / r.sample_count : 0
|
||||
if (r.rec_start_ms != null && r.rec_end_ms != null && r.sample_count > 0) {
|
||||
const dtMs = Number((r.rec_end_ms as bigint) - (r.rec_start_ms as bigint))
|
||||
if (Number.isFinite(dtMs) && dtMs > 0) step = dtMs / 1000 / r.sample_count
|
||||
if (Number.isFinite(dtMs) && dtMs > 0) stepMs = dtMs / r.sample_count
|
||||
}
|
||||
const hasFit = r.fit_a != null
|
||||
for (let i = 0; i < r.code_data.length; i++) {
|
||||
const t = (i * step).toFixed(6)
|
||||
const t = (i * stepMs).toFixed(3)
|
||||
const code = r.code_data[i]
|
||||
const force = hasFit ? r.fit_a! * code + (r.fit_b ?? 0) : ''
|
||||
csv += `${r.id},${new Date(r.timestamp).toISOString()},${i},${t},${code},${hasFit ? force : ''}\n`
|
||||
csv += `${i},${t},${code},${hasFit ? force : ''}\n`
|
||||
}
|
||||
}
|
||||
return new Response(csv, {
|
||||
|
||||
Reference in New Issue
Block a user