(&self, query: &str, limit: usize)
| 1617 | } |
| 1618 | |
| 1619 | pub async fn search_code_projects(&self, query: &str, limit: usize) -> Vec<CodeProjectRecord> { |
| 1620 | let limit = i64::try_from(limit).unwrap_or(i64::MAX); |
| 1621 | let pattern = like_pattern(query); |
| 1622 | let Ok(mut rows) = self |
| 1623 | .conn |
| 1624 | .query( |
| 1625 | "SELECT DISTINCT cp.project_id, cp.canonical_root, cp.display_root, |
| 1626 | cp.git_common_dir, cp.git_remote_url, cp.default_branch, |
| 1627 | cp.created_at, cp.last_seen_at |
| 1628 | FROM code_projects cp |
| 1629 | LEFT JOIN project_aliases pa ON pa.project_id = cp.project_id |
| 1630 | WHERE cp.project_id LIKE ?1 ESCAPE '\\' |
| 1631 | OR cp.canonical_root LIKE ?1 ESCAPE '\\' |
| 1632 | OR cp.display_root LIKE ?1 ESCAPE '\\' |
| 1633 | OR COALESCE(cp.git_common_dir, '') LIKE ?1 ESCAPE '\\' |
| 1634 | OR COALESCE(cp.git_remote_url, '') LIKE ?1 ESCAPE '\\' |
| 1635 | OR COALESCE(cp.default_branch, '') LIKE ?1 ESCAPE '\\' |
| 1636 | OR COALESCE(pa.alias_path, '') LIKE ?1 ESCAPE '\\' |
| 1637 | ORDER BY cp.last_seen_at DESC, cp.project_id |
| 1638 | LIMIT ?2", |
| 1639 | params![pattern, limit], |
| 1640 | ) |
| 1641 | .await |
| 1642 | else { |
| 1643 | return Vec::new(); |
| 1644 | }; |
| 1645 | let mut projects = Vec::new(); |
| 1646 | while let Ok(Some(row)) = rows.next().await { |
| 1647 | if let Some(project) = row_to_code_project(&row, 0) { |
| 1648 | projects.push(project); |
| 1649 | } |
| 1650 | } |
| 1651 | projects |
| 1652 | } |
| 1653 | |
| 1654 | pub async fn project_registry_context_by_id( |
| 1655 | &self, |
no test coverage detected