UBER-1052: Fix remainings (#3844)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2023-10-16 23:02:42 +07:00
committed by GitHub
parent 0b3b5725ca
commit 3c0ff4c049
19 changed files with 226 additions and 39 deletions
+15 -1
View File
@@ -270,6 +270,7 @@ async function doTimeReportUpdate (cud: TxCUD<TimeSpendReport>, tx: Tx, control:
]
const [currentIssue] = await control.findAll(tracker.class.Issue, { _id: parentTx.objectId }, { limit: 1 })
currentIssue.reportedTime += ccud.attributes.value
currentIssue.remainingTime = Math.max(0, currentIssue.estimation - currentIssue.reportedTime)
updateIssueParentEstimations(currentIssue, res, control, currentIssue.parents, currentIssue.parents)
return res
}
@@ -294,6 +295,7 @@ async function doTimeReportUpdate (cud: TxCUD<TimeSpendReport>, tx: Tx, control:
)
currentIssue.reportedTime -= doc.value
currentIssue.reportedTime += upd.operations.value
currentIssue.remainingTime = Math.max(0, currentIssue.estimation - currentIssue.reportedTime)
}
updateIssueParentEstimations(currentIssue, res, control, currentIssue.parents, currentIssue.parents)
@@ -317,6 +319,7 @@ async function doTimeReportUpdate (cud: TxCUD<TimeSpendReport>, tx: Tx, control:
]
const [currentIssue] = await control.findAll(tracker.class.Issue, { _id: parentTx.objectId }, { limit: 1 })
currentIssue.reportedTime -= doc.value
currentIssue.remainingTime = Math.max(0, currentIssue.estimation - currentIssue.reportedTime)
updateIssueParentEstimations(currentIssue, res, control, currentIssue.parents, currentIssue.parents)
return res
}
@@ -377,12 +380,23 @@ async function doIssueUpdate (
if (
Object.prototype.hasOwnProperty.call(updateTx.operations, 'estimation') ||
Object.prototype.hasOwnProperty.call(updateTx.operations, 'reportedTime')
Object.prototype.hasOwnProperty.call(updateTx.operations, 'reportedTime') ||
(Object.prototype.hasOwnProperty.call(updateTx.operations, '$inc') &&
Object.prototype.hasOwnProperty.call(updateTx.operations.$inc, 'reportedTime')) ||
(Object.prototype.hasOwnProperty.call(updateTx.operations, '$dec') &&
Object.prototype.hasOwnProperty.call(updateTx.operations.$inc, 'reportedTime'))
) {
const issue = await getCurrentIssue()
issue.estimation = updateTx.operations.estimation ?? issue.estimation
issue.reportedTime = updateTx.operations.reportedTime ?? issue.reportedTime
issue.remainingTime = Math.max(0, issue.estimation - issue.reportedTime)
res.push(
control.txFactory.createTxUpdateDoc(tracker.class.Issue, issue.space, issue._id, {
remainingTime: issue.remainingTime
})
)
updateIssueParentEstimations(issue, res, control, issue.parents, issue.parents)
}