Skip to content

Commit

Permalink
feat: add fetch repository if it not already exist in db (#530)
Browse files Browse the repository at this point in the history
* feat: add fetch repository if it not already exist in db

* feat: add fetch repository if it not already exist in db

* style: go fmt

* style: go fmt
  • Loading branch information
MikaelVallenet authored Aug 4, 2022
1 parent c05469a commit 3d8c21d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/dvserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ func (s *service) Graph(ctx context.Context, in *Graph_Input) (*Graph_Output, er
return nil, fmt.Errorf("load tasks: %w", err)
}

// fetch if not already in db
if len(tasks) == 0 {
_, err := dvcore.PullAndSave(filters.Targets, s.h, s.schema, s.opts.GitHubToken, false, s.opts.Logger)
if err != nil {
return nil, fmt.Errorf("pull: %w", err)
}
tasks, err = dvstore.LoadTasks(s.h, s.schema, filters, s.opts.Logger)
if err != nil {
return nil, fmt.Errorf("load tasks: %w", err)
}
}

// build output
ret := Graph_Output{
Tasks: make([]*dvmodel.Task, len(tasks)),
Expand Down

0 comments on commit 3d8c21d

Please sign in to comment.