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
|
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 }) {
|
export default function TelemetryView({ idWell }) {
|
||||||
const [dataSaub, setDataSaub] = useState([])
|
const [dataSaub, setDataSaub] = useState([])
|
||||||
const [dataSpin, setDataSpin] = useState([])
|
const [dataSpin, setDataSpin] = useState([])
|
||||||
@ -300,15 +308,9 @@ export default function TelemetryView({ idWell }) {
|
|||||||
|
|
||||||
const handleDataSaub = (data) => {
|
const handleDataSaub = (data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
data.forEach((_, idx) => {
|
const dataSaub = normalizeData(data)
|
||||||
if (data[idx].rotorSpeed < 1)
|
dataSaub.sort(sortByDate)
|
||||||
data[idx].rotorSpeed = 0;
|
setDataSaub(dataSaub)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user