Skip to content

Commit

Permalink
Fix #584 The individual attempts to OPT-IN or OPT-OUT to multiple DA(…
Browse files Browse the repository at this point in the history
…s) records should be listed in the consent records according to timestamp
  • Loading branch information
albinpa authored and georgepadayatti committed Nov 27, 2023
1 parent fcffce2 commit f92460e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/handler/v2/audit/audit_list_dataagreement_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"log"
"net/http"
"sort"
"time"

"github.com/bb-consent/api/internal/common"
"github.com/bb-consent/api/internal/config"
Expand Down Expand Up @@ -144,6 +146,13 @@ func AuditListDataAgreementRecords(w http.ResponseWriter, r *http.Request) {
return
}

// Sort the consentRecords based on timestamp
sort.SliceStable(consentRecords, func(i, j int) bool {
timeI, _ := time.Parse(time.RFC3339, consentRecords[i].Timestamp)
timeJ, _ := time.Parse(time.RFC3339, consentRecords[j].Timestamp)
return timeI.After(timeJ)
})

query := paginate.PaginateObjectsQuery{
Limit: limit,
Offset: offset,
Expand Down

0 comments on commit f92460e

Please sign in to comment.