Skip to content

Commit

Permalink
Copy in the only thing we were using golang/x/exp for (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Feb 13, 2024
1 parent cc35ef2 commit 457f308
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0
go.opentelemetry.io/otel/sdk v1.22.0
go.opentelemetry.io/otel/trace v1.22.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/mod v0.14.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.17.0
Expand Down Expand Up @@ -122,6 +121,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.6.0 // indirect
Expand Down
13 changes: 10 additions & 3 deletions internal/app/dashboard_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"golang.org/x/exp/maps"
)

// An lpaLink is used to join an actor to an LPA.
Expand Down Expand Up @@ -179,8 +178,8 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica
}
}

certificateProvider = maps.Values(certificateProviderMap)
attorney = maps.Values(attorneyMap)
certificateProvider = mapValues(certificateProviderMap)
attorney = mapValues(attorneyMap)

byUpdatedAt := func(a, b page.LpaAndActorTasks) int {
if a.Donor.UpdatedAt.After(b.Donor.UpdatedAt) {
Expand All @@ -195,3 +194,11 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica

return donor, attorney, certificateProvider, nil
}

func mapValues[M ~map[K]V, K comparable, V any](m M) []V {
r := make([]V, 0, len(m))
for _, v := range m {
r = append(r, v)
}
return r
}

0 comments on commit 457f308

Please sign in to comment.