我想执行以下操作:
我想返回一个用户列表,首先按用户“关注”的人排序,其次是一些额外的分数。但是,我在下面编写的以下代码不起作用,因为资助者是提升的 Slick 类型,因此从未在列表中找到。
//The following represents the query for only funders who we are following
val following_funders: List[User] = (
for {
funder <- all_funders
f <- follows if f.followerId === id //get all the current users follower objects
if f.followeeId === funder.id
} yield funder
).list
val all_funders_sorted = for {
funder <- all_funders
following_funder = following_funders contains funder
} yield (funder, following_funder)
//sort the funders by whether or not they are following the funder and then map it to only the funders (i.e. remove the boolean)
all_funders_sorted.sortBy(_._2.desc).sortBy(_._1.score.desc).map( x => x._1 )
所有帮助表示赞赏!