Browse Source

fix sorting on the front page only?

master
Gisle Aune 2 years ago
parent
commit
2f4a85f0a9
  1. 14
      ports/mysql/items.go

14
ports/mysql/items.go

@ -179,6 +179,7 @@ func (r *itemRepository) Fetch(ctx context.Context, filter models.ItemFilter) ([
}
// Scheduled date, ascending
cti, ctj := res[i].CreatedTime, res[j].CreatedTime
sdi, sdj := res[i].ScheduledDate, res[j].ScheduledDate
if sdi != nil && sdj == nil {
return true
@ -186,12 +187,21 @@ func (r *itemRepository) Fetch(ctx context.Context, filter models.ItemFilter) ([
if sdi == nil && sdj != nil {
return false
}
if sdi != nil && sdj != nil && *sdi != *sdj {
if sdi != nil && sdj != nil {
if *sdi != *sdj {
// This should change the behavior on the front page only. #hax
if filter.UnAcquired {
return cti.Before(ctj)
} else {
return cti.After(ctj)
}
}
return sdi.Before(*sdj)
}
// Created time, descending
return res[i].CreatedTime.After(res[j].CreatedTime)
return cti.After(ctj)
})
return res, nil

Loading…
Cancel
Save