forked from ddrilling/asb_cloud_front
Нормализация значений и сортировка по дате вынесены в функции
This commit is contained in:
parent
4f0e30127c
commit
909ed39faf
@ -290,6 +290,14 @@ const getIndexOfDrillingBy = (dataSaub) => {
|
||||
return order[idFeedRegulator] ?? -1
|
||||
}
|
||||
|
||||
export const sortByDate = (a, b) => a.date > b.date ? 1 : -1
|
||||
export const normalizeData = (data) => data?.map(item => ({
|
||||
...item,
|
||||
rotorSpeed: item.rotorSpeed < 1 ? 0 : item.rotorSpeed,
|
||||
rotorTorque: item.rotorTorque < 1 ? 0 : item.rotorTorque,
|
||||
blockSpeed: Math.abs(item.blockSpeed)
|
||||
})) ?? []
|
||||
|
||||
export default function TelemetryView({ idWell }) {
|
||||
const [dataSaub, setDataSaub] = useState([])
|
||||
const [dataSpin, setDataSpin] = useState([])
|
||||
@ -300,15 +308,9 @@ export default function TelemetryView({ idWell }) {
|
||||
|
||||
const handleDataSaub = (data) => {
|
||||
if (data) {
|
||||
data.forEach((_, idx) => {
|
||||
if (data[idx].rotorSpeed < 1)
|
||||
data[idx].rotorSpeed = 0;
|
||||
if (data[idx].rotorTorque < 1)
|
||||
data[idx].rotorTorque = 0;
|
||||
data[idx].blockSpeed = Math.abs(data[idx].blockSpeed)
|
||||
})
|
||||
data.sort((a, b) => a.date > b.date ? 1 : -1)
|
||||
setDataSaub(data)
|
||||
const dataSaub = normalizeData(data)
|
||||
dataSaub.sort(sortByDate)
|
||||
setDataSaub(dataSaub)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user