Skip to content

Commit

Permalink
add sort slice function (#3463)
Browse files Browse the repository at this point in the history
  • Loading branch information
racheljay authored Aug 22, 2023
1 parent 8be7d49 commit f6bc946
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/test_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"net/http"
"os"
"sort"

"github.com/web-platform-tests/wpt.fyi/shared"
)
Expand Down Expand Up @@ -63,6 +64,11 @@ func testHistoryHandler(w http.ResponseWriter, r *http.Request) {
log.Print(err)
}

// Sort runs in chronological order
sort.Slice(runs, func(i, j int) bool {
return runs[i].Date < runs[j].Date
})

// If there are no runs returned, return backup mock JSON
if len(runs) == 0 {
jsonData, jsonErr := os.ReadFile("./api/test-data/mock_history_data.json")
Expand Down

0 comments on commit f6bc946

Please sign in to comment.