Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 'the world' target #204

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/dvcore/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func Run(h *cayley.Handle, args []string, opts RunOpts) error {
}
opts.Logger.Debug("Run called", zap.Strings("args", args), zap.Any("opts", opts))

// FIXME: support the world

targets, err := dvparser.ParseTargets(args)
if err != nil {
return fmt.Errorf("parse targets: %w", err)
Expand Down
14 changes: 9 additions & 5 deletions internal/dvserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ func (s *service) Graph(ctx context.Context, in *Graph_Input) (*Graph_Output, er
return nil, fmt.Errorf("targets is required")
}

targets, err := dvparser.ParseTargets(in.Targets)
if err != nil {
return nil, fmt.Errorf("parse targets: %w", err)
}
filters := dvstore.LoadTasksFilters{
WithClosed: in.WithClosed,
WithoutIsolated: in.WithoutIsolated,
WithoutPRs: in.WithoutPRs,
WithoutExternalDeps: in.WithoutExternalDeps,
Targets: targets,
}
if len(in.Targets) == 1 && in.Targets[0] == "world" {
filters.TheWorld = true
} else {
targets, err := dvparser.ParseTargets(in.Targets)
if err != nil {
return nil, fmt.Errorf("parse targets: %w", err)
}
filters.Targets = targets
}

// load tasks
Expand Down
55 changes: 30 additions & 25 deletions internal/dvstore/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,56 @@ func LastUpdatedIssueInRepo(ctx context.Context, h *cayley.Handle, entity multip

type LoadTasksFilters struct {
Targets []multipmuri.Entity
TheWorld bool
WithClosed bool
WithoutIsolated bool
WithoutPRs bool
WithoutExternalDeps bool
}

func LoadTasks(h *cayley.Handle, schema *schema.Config, filters LoadTasksFilters, logger *zap.Logger) (dvmodel.Tasks, error) {
if filters.Targets == nil || len(filters.Targets) == 0 {
if (filters.Targets == nil || len(filters.Targets) == 0) && !filters.TheWorld {
return nil, fmt.Errorf("missing filter.targets")
}

ctx := context.TODO()

// fetch and filter
// fetch targets
paths := []*path.Path{}
for _, target := range filters.Targets {
// FIXME: handle different target types (for now only repo)
p := path.StartPath(h, quad.IRI(target.String())).
In().
Has(quad.IRI("rdf:type"), quad.IRI("dv:Task"))
kinds := []quad.Value{
quad.Int(dvmodel.Task_Issue),
quad.Int(dvmodel.Task_Milestone),
quad.Int(dvmodel.Task_Epic),
quad.Int(dvmodel.Task_Story),
quad.Int(dvmodel.Task_Card),
if filters.TheWorld {
paths = append(paths, path.StartPath(h))
} else {
for _, target := range filters.Targets {
// FIXME: handle different target types (for now only repo)
p := path.StartPath(h, quad.IRI(target.String())).
Both().
Has(quad.IRI("rdf:type"), quad.IRI("dv:Task"))

// FIXME: reverse depends/blocks
paths = append(paths, p)
}
// FIXME: one option per type
if !filters.WithoutPRs {
kinds = append(kinds, quad.Int(dvmodel.Task_MergeRequest))
}
p = p.Has(quad.IRI("schema:kind"), kinds...)
if !filters.WithClosed {
p = p.Has(quad.IRI("schema:state"), quad.Int(dvmodel.Task_Open))
}
// FIXME: reverse depends/blocks

paths = append(paths, p)
}

p := paths[0]
for _, path := range paths[1:] {
p = p.Or(path)
}

// filters
kinds := []quad.Value{
quad.Int(dvmodel.Task_Issue),
quad.Int(dvmodel.Task_Milestone),
quad.Int(dvmodel.Task_Epic),
quad.Int(dvmodel.Task_Story),
quad.Int(dvmodel.Task_Card),
}
if !filters.WithoutPRs {
kinds = append(kinds, quad.Int(dvmodel.Task_MergeRequest))
}
p = p.Has(quad.IRI("schema:kind"), kinds...)
if !filters.WithClosed {
p = p.Has(quad.IRI("schema:state"), quad.Int(dvmodel.Task_Open))
}

if !filters.WithoutExternalDeps {
p = p.Or(p.Both(
quad.IRI("isDependingOn"),
Expand Down