Skip to content

Commit

Permalink
feat(policy): allow provider config to specify to latest policy versi…
Browse files Browse the repository at this point in the history
…on (#130)

* feat(policy): latest policy mapping

* unit test

* update unit test

* update unit test

* fix latest for each policy id

* update comment

* update flow set latest

* Update core/appeal/service_test.go

Co-authored-by: Rahmat Hidayat <[email protected]>

* Update core/appeal/service_test.go

Co-authored-by: Rahmat Hidayat <[email protected]>

* Update core/appeal/service_test.go

Co-authored-by: Rahmat Hidayat <[email protected]>

---------

Co-authored-by: Muhammad Idil Haq Amir <[email protected]>
Co-authored-by: Rahmat Hidayat <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 407b192 commit 1aa0327
Show file tree
Hide file tree
Showing 2 changed files with 457 additions and 7 deletions.
8 changes: 6 additions & 2 deletions core/appeal/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,18 @@ func (s *Service) getPoliciesMap(ctx context.Context) (map[string]map[uint]*doma
if err != nil {
return nil, err
}

policiesMap := map[string]map[uint]*domain.Policy{}
for _, p := range policies {
id := p.ID
version := p.Version
if policiesMap[id] == nil {
policiesMap[id] = map[uint]*domain.Policy{}
}
policiesMap[id][version] = p
policiesMap[id][p.Version] = p
// set policiesMap[id][0] to latest policy version
if policiesMap[id][0] == nil || p.Version > policiesMap[id][0].Version {
policiesMap[id][0] = p
}
}

return policiesMap, nil
Expand Down
Loading

0 comments on commit 1aa0327

Please sign in to comment.