INNER CODE UNIT · Rust
flag_voters
zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:452
fn flag_voters(&self, content_type: &str, content_id: &str) -> Vec<AigcFlagVoter> {
let mut voters = self
.flags
.iter()
.filter(|(key, _)| key.content_type == content_type && key.content_id == content_id)
.map(|(_, record)| {
flag_voter_from_identity(&record.voter, record.created_at, record.credit_bypassed)
})
.collect::<Vec<_>>();
voters.sort_by(|left, right| right.created_at.cmp(&left.created_at));
voters.truncate(10);
voters
}
}
#[async_trait]
impl VoteStore for MemoryVoteStore {
async fn health(&self) -> Result<(), ServiceError> {