Skip to content

Commit

Permalink
Removed unnecessary Principal model
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pfohl committed Jun 29, 2023
1 parent 3422867 commit 25a6c54
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion components/printer/work_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func printHeadline(workPackage *models.WorkPackage, maxIdLength, maxStatusLength
func printAttributes(workPackage *models.WorkPackage) {
activePrinter.Printf("[%s]\n", Yellow(workPackage.Status))

assigneeStr := workPackage.Assignee.Name
assigneeStr := workPackage.Assignee
if len(assigneeStr) == 0 {
assigneeStr = "-"
}
Expand Down
10 changes: 5 additions & 5 deletions components/printer/work_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestWorkPackage(t *testing.T) {
Id: 42,
Subject: "Test",
Type: "TASK",
Assignee: models.Principal{Name: "Aaron"},
Assignee: "Aaron",
Status: "New",
Description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non est sed nunc euismod luctus. Donec vehicula scelerisque efficitur. Nunc arcu ligula, dictum maximus consequat id, tincidunt vitae augue. Vestibulum ut tellus id nisi faucibus efficitur id eu tortor. Vestibulum sed vehicula turpis, sit amet eleifend massa. Proin eu quam justo. Nulla id libero sit amet turpis venenatis mollis. Quisque iaculis lectus non ligula faucibus, ut pellentesque velit sodales. Vivamus nibh est, molestie at laoreet nec, lacinia porttitor nisl. Nulla eget urna in enim porttitor tempus. Nullam velit nunc, ultrices eget molestie vitae, tincidunt vitae felis.
Expand Down Expand Up @@ -53,7 +53,7 @@ commodo enim ligula nec sem. Pellentesque nec tincidunt sapien.`
idString := "#" + strconv.FormatUint(workPackage.Id, 10)
expected += fmt.Sprintf("%s %s %s\n", printer.Red(idString), printer.Green(workPackage.Type), printer.Cyan(workPackage.Subject))
expected += fmt.Sprintf("[%s]\n", printer.Yellow(workPackage.Status))
expected += fmt.Sprintf("Assignee: %s\n\n", workPackage.Assignee.Name)
expected += fmt.Sprintf("Assignee: %s\n\n", workPackage.Assignee)
expected += fmt.Sprintf("Open: %s\n\n", routes.WorkPackageUrl(&workPackage))
expected += fmt.Sprintln(expectedDescription)

Expand All @@ -71,7 +71,7 @@ func TestWorkPackage_Assignee_With_Empty_String(t *testing.T) {
Id: 42,
Subject: "Test",
Type: "TASK",
Assignee: models.Principal{Name: ""},
Assignee: "",
Status: "New",
Description: "This is an example.",
LockVersion: 0,
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestWorkPackages(t *testing.T) {
Id: 42,
Subject: "Test 1",
Type: "PHASE",
Assignee: models.Principal{Name: "Obi-Wan"},
Assignee: "Obi-Wan",
Status: "In progress",
Description: "This is one example.",
LockVersion: 0,
Expand All @@ -110,7 +110,7 @@ func TestWorkPackages(t *testing.T) {
Id: 43,
Subject: "Test 2",
Type: "TASK",
Assignee: models.Principal{Name: "Anakin"},
Assignee: "Anakin",
Status: "New",
Description: "This is another example.",
LockVersion: 0,
Expand Down
5 changes: 2 additions & 3 deletions components/resources/work_packages/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package work_packages

import (
"github.com/opf/openproject-cli/components/requests"
"github.com/opf/openproject-cli/models"
)

func AssigneeFilter(principal *models.Principal) requests.Filter {
func AssigneeFilter(name string) requests.Filter {
return requests.Filter{
Operator: "=",
Name: "assignee",
Values: []string{principal.Name},
Values: []string{name},
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/resources/work_packages/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func All(filterOptions *map[FilterOption]string) ([]*models.WorkPackage, error)
for updateOpt, value := range *filterOptions {
switch updateOpt {
case Assignee:
filters = append(filters, AssigneeFilter(&models.Principal{Name: value}))
filters = append(filters, AssigneeFilter(value))
case Version:
filters = append(filters, VersionFilter(value))
case Project:
Expand Down
2 changes: 1 addition & 1 deletion dtos/work_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (dto *WorkPackageDto) Convert() *models.WorkPackage {
Id: uint64(dto.Id),
Subject: dto.Subject,
Type: dto.Links.Type.Title,
Assignee: models.Principal{Name: dto.Links.Assignee.Title},
Assignee: dto.Links.Assignee.Title,
Status: dto.Links.Status.Title,
Description: dto.Description.Raw,
LockVersion: dto.LockVersion,
Expand Down
5 changes: 0 additions & 5 deletions models/principal.go

This file was deleted.

2 changes: 1 addition & 1 deletion models/work_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type WorkPackage struct {
Id uint64
Subject string
Type string
Assignee Principal
Assignee string
Status string
Description string
LockVersion int
Expand Down

0 comments on commit 25a6c54

Please sign in to comment.