add: questions api endpoints
This commit is contained in:
parent
b29760d7ec
commit
d128b2c438
5 changed files with 321 additions and 4 deletions
|
@ -76,6 +76,21 @@ impl DataManager {
|
|||
Ok(out)
|
||||
}
|
||||
|
||||
/// Filter to update questions to clean their owner for public APIs.
|
||||
pub fn questions_owner_filter(
|
||||
&self,
|
||||
questions: &Vec<(Question, User)>,
|
||||
) -> Vec<(Question, User)> {
|
||||
let mut out: Vec<(Question, User)> = Vec::new();
|
||||
|
||||
for mut question in questions.clone() {
|
||||
question.1.clean();
|
||||
out.push(question);
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
/// Get all questions by `owner`.
|
||||
pub async fn get_questions_by_owner(&self, owner: usize) -> Result<Vec<Question>> {
|
||||
let conn = match self.0.connect().await {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue