mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 12:04:56 +02:00
UBER-1052: Fix remainings (#3844)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user