2024-05-25 11:45:25 +00:00
|
|
|
package activities
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/mentos1386/zdravko/database/models"
|
|
|
|
"github.com/mentos1386/zdravko/internal/server/services"
|
|
|
|
"github.com/mentos1386/zdravko/internal/temporal"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (a *Activities) AddTargetHistory(ctx context.Context, param temporal.ActivityAddTargetHistoryParam) (*temporal.ActivityAddTargetHistoryResult, error) {
|
|
|
|
|
|
|
|
status := models.TargetStatusUnknown
|
|
|
|
if param.Status == temporal.AddTargetHistoryStatusSuccess {
|
|
|
|
status = models.TargetStatusSuccess
|
|
|
|
}
|
|
|
|
if param.Status == temporal.AddTargetHistoryStatusFailure {
|
|
|
|
status = models.TargetStatusFailure
|
|
|
|
}
|
|
|
|
|
|
|
|
err := services.AddHistoryForTarget(ctx, a.db, &models.TargetHistory{
|
2024-05-25 17:52:37 +00:00
|
|
|
TargetId: param.Target.Id,
|
|
|
|
WorkerGroupId: param.WorkerGroupId,
|
|
|
|
CheckId: param.CheckId,
|
|
|
|
Status: status,
|
|
|
|
Note: param.Note,
|
2024-05-25 11:45:25 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return &temporal.ActivityAddTargetHistoryResult{}, err
|
|
|
|
}
|