Skip to content

Commit

Permalink
Correct timestamp in 'tink workflow get <id>' command
Browse files Browse the repository at this point in the history
Signed-off-by: parauliya <[email protected]>
  • Loading branch information
parauliya committed Apr 21, 2021
1 parent 0f46dc0 commit b217be8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
19 changes: 15 additions & 4 deletions db/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,29 @@ func (d TinkDB) GetWorkflowsForWorker(id string) ([]string, error) {
// GetWorkflow returns a workflow
func (d TinkDB) GetWorkflow(ctx context.Context, id string) (Workflow, error) {
query := `
SELECT template, devices
SELECT template, devices, created_at, updated_at
FROM workflow
WHERE
id = $1
AND
deleted_at IS NULL;
`
row := d.instance.QueryRowContext(ctx, query, id)
var tmp, tar string
err := row.Scan(&tmp, &tar)
var (
tmp, tar string
crAt, upAt time.Time
)
err := row.Scan(&tmp, &tar, &crAt, &upAt)
if err == nil {
return Workflow{ID: id, Template: tmp, Hardware: tar}, nil
createdAt, _ := ptypes.TimestampProto(crAt)
updatedAt, _ := ptypes.TimestampProto(upAt)
return Workflow{
ID: id,
Template: tmp,
Hardware: tar,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
}, nil
}
if err != sql.ErrNoRows {
err = errors.Wrap(err, "SELECT")
Expand Down
12 changes: 7 additions & 5 deletions grpc-server/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ func (s *server) GetWorkflow(ctx context.Context, in *workflow.GetRequest) (*wor
}

wf := &workflow.Workflow{
Id: w.ID,
Template: w.Template,
Hardware: w.Hardware,
State: getWorkflowState(s.db, ctx, in.Id),
Data: data,
Id: w.ID,
Template: w.Template,
Hardware: w.Hardware,
State: getWorkflowState(s.db, ctx, in.Id),
CreatedAt: w.CreatedAt,
UpdatedAt: w.UpdatedAt,
Data: data,
}
l := s.logger.With("workflowID", w.ID)
l.Info("done " + msg)
Expand Down

0 comments on commit b217be8

Please sign in to comment.