Open sstojak1 opened 1 week ago
The issue with the began_at
field in the _devlake_tasks
table mirroring the value from the _devlake_pipelines
table is due to the began_at
field not being set correctly for individual tasks. To resolve this, ensure that the began_at
field for each task is set when the task starts, rather than inheriting the value from the pipeline.
Here's an example of how to set the began_at
field correctly:
func StartTask(task *Task) {
now := time.Now()
task.BeganAt = &now
// Save the task to the database
db.Save(task)
}
This function should be called when the task starts, ensuring that the began_at
field is set to the current time. This will help in accurately calculating the spent_seconds
field.
Additionally, you can use the logging functionality provided by the getTaskLogger
function to trace the exact point at which the began_at
field is set. Add logging right before and after setting the began_at
field:
logger.Info("Setting began_at for task: %d", task.ID)
beganAt := time.Now()
if task.BeganAt != nil {
beganAt = *task.BeganAt
}
logger.Info("began_at set to: %v for task: %d", beganAt, task.ID)
This will help you trace and debug the setting of the began_at
field for tasks [1][2].
To continue talking to Dosu, mention @dosu.
Search before asking
What happened
The
_devlake_tasks
table lists the tasks associated with a specific pipeline from the_devlake_pipelines
table.There is an issue with the
began_at
field in the_devlake_tasks
table, as it currently mirrors the value in the_devlake_pipelines
table. This causes thespent_seconds
field to be inaccurate, making it difficult to calculate the correct duration of a task.What do you expect to happen
began_at value is correctly populated for
_devlake_tasks
table.How to reproduce
began_at
field in the_devlake_tasks
table.Anything else
No response
Version
v1.0.0-beta3
Are you willing to submit PR?
Code of Conduct