Skip to content

Commit

Permalink
Sort by Due asc on the flashcard management UI
Browse files Browse the repository at this point in the history
  • Loading branch information
debbbbie committed Nov 17, 2023
1 parent 0359f96 commit 1808b6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kernel/model/flashcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,17 @@ func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCo
return
}

// sort by due date asc
sort.Slice(cards, func(i, j int) bool {
due1 := cards[i].(*riff.FSRSCard).C.Due
due2 := cards[j].(*riff.FSRSCard).C.Due
return due1.Before(due2)
})

var blockIDs []string
for _, card := range cards {
blockIDs = append(blockIDs, card.BlockID())
}
sort.Strings(blockIDs)

sqlBlocks := sql.GetBlocks(blockIDs)
blocks = fromSQLBlocks(&sqlBlocks, "", 36)
Expand Down

0 comments on commit 1808b6c

Please sign in to comment.