(&self, pool: &PgPool)
| 56 | } |
| 57 | |
| 58 | pub async fn call(&self, pool: &PgPool) -> Result<Vec<Repository>> { |
| 59 | log::debug!("fetching repositories for user {:?}", self.user_id); |
| 60 | |
| 61 | let query = format!( |
| 62 | r#" |
| 63 | select |
| 64 | {REPOSITORY_FIELDS} |
| 65 | {REPOSITORY_JOINS} |
| 66 | join users_repositories ur on r.id = ur.repository_id |
| 67 | where ur.user_id = $1::uuid |
| 68 | and r.id = any($2::uuid[]) |
| 69 | and ur.can_write |
| 70 | group by r.id, ur.user_id |
| 71 | "#, |
| 72 | ); |
| 73 | let rows = sqlx::query_as::<_, Row>(&query) |
| 74 | .bind(&self.user_id) |
| 75 | .bind(self.viewer.write_repo_ids.to_vec()) |
| 76 | .fetch_all(pool) |
| 77 | .await?; |
| 78 | |
| 79 | Ok(rows.iter().map(Row::to_repository).collect()) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | pub struct RepositoryLoader { |
nothing calls this directly
no test coverage detected