| 1530 | } |
| 1531 | |
| 1532 | pub async fn list_code_projects(&self, limit: usize) -> Vec<CodeProjectRecord> { |
| 1533 | let limit = i64::try_from(limit).unwrap_or(i64::MAX); |
| 1534 | let Ok(mut rows) = self |
| 1535 | .conn |
| 1536 | .query( |
| 1537 | "SELECT project_id, canonical_root, display_root, git_common_dir, |
| 1538 | git_remote_url, default_branch, created_at, last_seen_at |
| 1539 | FROM code_projects |
| 1540 | ORDER BY last_seen_at DESC, project_id |
| 1541 | LIMIT ?1", |
| 1542 | params![limit], |
| 1543 | ) |
| 1544 | .await |
| 1545 | else { |
| 1546 | return Vec::new(); |
| 1547 | }; |
| 1548 | let mut projects = Vec::new(); |
| 1549 | while let Ok(Some(row)) = rows.next().await { |
| 1550 | if let Some(project) = row_to_code_project(&row, 0) { |
| 1551 | projects.push(project); |
| 1552 | } |
| 1553 | } |
| 1554 | projects |
| 1555 | } |
| 1556 | |
| 1557 | /// Returns registered code projects whose `last_seen_at` is within the last |
| 1558 | /// `since_secs` seconds, most-recently-seen first, capped at `limit`. |