diff --git a/server/bleep/src/agent.rs b/server/bleep/src/agent.rs index 06fdcdac6d..4efdfab625 100644 --- a/server/bleep/src/agent.rs +++ b/server/bleep/src/agent.rs @@ -405,7 +405,7 @@ impl Agent { query: &str, ) -> impl Iterator + 'a { let langs = self.last_exchange().query.langs.iter().map(Deref::deref); - let user_id = self.user.username().expect("didn't have user ID"); + let user_id = "1"; let (repos, branches): (Vec<_>, Vec<_>) = sqlx::query! { "SELECT pr.repo_ref, pr.branch @@ -441,23 +441,12 @@ impl Agent { fn store(&mut self) -> impl Future { let sql = Arc::clone(&self.app.sql); - let user_id = self - .user - .username() - .context("didn't have user ID") - .map(str::to_owned); + let user_id = "1".to_string(); let conversation = self.conversation.clone(); async move { - let result = match user_id { - Ok(user_id) => conversation.store(&sql, &user_id).await, - Err(e) => Err(e), - }; - - if let Err(e) = result { - error!("failed to store conversation: {e}"); - } + conversation.store(&sql, &user_id).await.expect("failed to store conversation"); } } } diff --git a/server/bleep/src/background.rs b/server/bleep/src/background.rs index f8838a8d0b..662e1aaac2 100644 --- a/server/bleep/src/background.rs +++ b/server/bleep/src/background.rs @@ -89,7 +89,7 @@ impl BackgroundExecutor { let tokio_ref = tokio_ref.clone(); let thread_priority = thread_priority::ThreadPriority::Max; - std::thread::Builder::new() + thread::Builder::new() .name("index-worker".to_owned()) .spawn_with_priority(thread_priority, move |_| { let _tokio = tokio_ref.enter(); diff --git a/server/bleep/src/cache.rs b/server/bleep/src/cache.rs index ac6511d120..a1f5478edc 100644 --- a/server/bleep/src/cache.rs +++ b/server/bleep/src/cache.rs @@ -548,7 +548,7 @@ impl<'a> ChunkCache<'a> { let branches_hash = blake3::hash(payload.branches.join("\n").as_ref()).to_string(); match self.cache.entry(id) { - scc::hash_map::Entry::Occupied(mut existing) => { + Entry::Occupied(mut existing) => { let key = existing.key(); trace!(?key, "found; not upserting new"); if existing.get().value != branches_hash { @@ -560,7 +560,7 @@ impl<'a> ChunkCache<'a> { } *existing.get_mut() = branches_hash.into(); } - scc::hash_map::Entry::Vacant(vacant) => { + Entry::Vacant(vacant) => { let key = vacant.key(); trace!(?key, "inserting new"); self.new_sql diff --git a/server/bleep/src/commits.rs b/server/bleep/src/commits.rs index 27b5d9e279..d9222e9b04 100644 --- a/server/bleep/src/commits.rs +++ b/server/bleep/src/commits.rs @@ -437,7 +437,7 @@ Assistant: initialisation"#, pub async fn generate_tutorial_questions( db: crate::db::SqlDb, - llm_gateway: Result, + llm_gateway: Result, repo_pool: RepositoryPool, reporef: RepoRef, ) -> Result<()> { diff --git a/server/bleep/src/indexes.rs b/server/bleep/src/indexes.rs index 2d9648cd69..bd2bb04738 100644 --- a/server/bleep/src/indexes.rs +++ b/server/bleep/src/indexes.rs @@ -118,11 +118,11 @@ impl Indexes { // we don't support old schemas, and tantivy will hard // error if we try to open a db with a different schema. if config.index_path("repo").as_ref().exists() { - std::fs::remove_dir_all(config.index_path("repo"))?; + fs::remove_dir_all(config.index_path("repo"))?; debug!("removed index repo dir") } if config.index_path("content").as_ref().exists() { - std::fs::remove_dir_all(config.index_path("content"))?; + fs::remove_dir_all(config.index_path("content"))?; debug!("removed index content dir") } Ok(()) diff --git a/server/bleep/src/indexes/schema.rs b/server/bleep/src/indexes/schema.rs index f7f0cd961a..f2f7d025f5 100644 --- a/server/bleep/src/indexes/schema.rs +++ b/server/bleep/src/indexes/schema.rs @@ -69,7 +69,7 @@ pub struct File { impl File { pub fn new() -> Self { - let mut builder = tantivy::schema::SchemaBuilder::new(); + let mut builder = SchemaBuilder::new(); let trigram = TextOptions::default().set_stored().set_indexing_options( TextFieldIndexing::default() .set_tokenizer("default") diff --git a/server/bleep/src/query/parser.rs b/server/bleep/src/query/parser.rs index 4f82efc00a..8be2b28eb0 100644 --- a/server/bleep/src/query/parser.rs +++ b/server/bleep/src/query/parser.rs @@ -356,7 +356,7 @@ impl<'a> Literal<'a> { /// Force this literal into the `Regex` variant. fn make_regex(&mut self) { - *self = match std::mem::take(self) { + *self = match mem::take(self) { Self::Plain(s) | Self::Regex(s) => Self::Regex(s), } } diff --git a/server/bleep/src/repo.rs b/server/bleep/src/repo.rs index 2868a816fe..9bdc2e0ea5 100644 --- a/server/bleep/src/repo.rs +++ b/server/bleep/src/repo.rs @@ -153,7 +153,7 @@ impl FromStr for RepoRef { } impl Display for RepoRef { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.backend() { Backend::Github => write!(f, "github.com/{}", self.name()), Backend::Local => write!(f, "local/{}", self.name()), diff --git a/server/bleep/src/webserver.rs b/server/bleep/src/webserver.rs index 1a324ff999..f6f898f921 100644 --- a/server/bleep/src/webserver.rs +++ b/server/bleep/src/webserver.rs @@ -254,7 +254,7 @@ impl Error { self } - fn internal(message: S) -> Self { + fn internal(message: S) -> Self { Error { status: StatusCode::INTERNAL_SERVER_ERROR, body: EndpointError { @@ -264,7 +264,7 @@ impl Error { } } - fn user(message: S) -> Self { + fn user(message: S) -> Self { Error { status: StatusCode::BAD_REQUEST, body: EndpointError { @@ -274,7 +274,7 @@ impl Error { } } - fn not_found(message: S) -> Self { + fn not_found(message: S) -> Self { Error { status: StatusCode::NOT_FOUND, body: EndpointError { @@ -360,7 +360,3 @@ async fn health(State(app): State) { // subsystem checks at this stage app.semantic.health_check().await.unwrap() } - -fn no_user_id() -> Error { - Error::user("didn't have user ID") -} diff --git a/server/bleep/src/webserver/answer.rs b/server/bleep/src/webserver/answer.rs index 527406b10d..451c60ed9e 100644 --- a/server/bleep/src/webserver/answer.rs +++ b/server/bleep/src/webserver/answer.rs @@ -73,7 +73,7 @@ pub(super) async fn answer( info!(?params.q, "handling /answer query"); let query_id = uuid::Uuid::new_v4(); - let user_id = user.username().ok_or_else(super::no_user_id)?; + let user_id = "1"; let mut conversation = match params.conversation_id { Some(conversation_id) => { @@ -173,7 +173,7 @@ impl AgentExecutor { async fn try_execute(&mut self) -> super::Result>> { QueryLog::new(&self.app.sql).insert(&self.params.q).await?; - let username = self.user.username().ok_or_else(super::no_user_id)?; + let username = "1"; let repo_refs = sqlx::query! { "SELECT repo_ref diff --git a/server/bleep/src/webserver/conversation.rs b/server/bleep/src/webserver/conversation.rs index 47111d4c61..e160a1e7a7 100644 --- a/server/bleep/src/webserver/conversation.rs +++ b/server/bleep/src/webserver/conversation.rs @@ -206,7 +206,7 @@ pub(in crate::webserver) async fn get( Path((project_id, conversation_id)): Path<(i64, i64)>, State(app): State, ) -> webserver::Result> { - let user_id = user.username().ok_or_else(super::no_user_id)?; + let user_id = "1"; let mut conversation = Conversation::load(&app.sql, user_id, project_id, conversation_id).await?; diff --git a/server/bleep/src/webserver/project.rs b/server/bleep/src/webserver/project.rs index 68dc06292b..0294372201 100644 --- a/server/bleep/src/webserver/project.rs +++ b/server/bleep/src/webserver/project.rs @@ -25,7 +25,7 @@ pub async fn list( app: Extension, user: Extension, ) -> webserver::Result>> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let projects = sqlx::query! { "SELECT p.id, p.name, ( @@ -91,7 +91,7 @@ pub async fn create( user: Extension, Json(params): Json, ) -> webserver::Result { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let project_id = sqlx::query! { "INSERT INTO projects (user_id, name) VALUES (?, ?) RETURNING id", @@ -118,7 +118,7 @@ pub async fn get( user: Extension, Path(id): Path, ) -> webserver::Result> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let row = sqlx::query! { "SELECT name, ( @@ -172,7 +172,7 @@ pub async fn update( Path(id): Path, Json(update): Json, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); sqlx::query! { "UPDATE projects SET name = ? WHERE id = ? AND user_id = ? RETURNING id", @@ -191,7 +191,7 @@ pub async fn delete( user: Extension, Path(id): Path, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?; + let user_id = "1".to_string(); sqlx::query! { "DELETE FROM projects WHERE id = ? AND user_id = ? RETURNING id", diff --git a/server/bleep/src/webserver/project/doc.rs b/server/bleep/src/webserver/project/doc.rs index 31c18936d1..c04f9bfc60 100644 --- a/server/bleep/src/webserver/project/doc.rs +++ b/server/bleep/src/webserver/project/doc.rs @@ -22,10 +22,7 @@ pub async fn list( user: Extension, Path(project_id): Path, ) -> webserver::Result>> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); let docs = sqlx::query_as! { Doc, @@ -57,10 +54,7 @@ pub async fn add( Path(project_id): Path, Json(params): Json, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); sqlx::query! { "SELECT id FROM projects WHERE id = ? AND user_id = ?", @@ -87,10 +81,7 @@ pub async fn delete( user: Extension, Path((project_id, doc_id)): Path<(i64, i64)>, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); sqlx::query! { "DELETE FROM project_docs diff --git a/server/bleep/src/webserver/project/repo.rs b/server/bleep/src/webserver/project/repo.rs index 9e88b97f7f..881312f8c0 100644 --- a/server/bleep/src/webserver/project/repo.rs +++ b/server/bleep/src/webserver/project/repo.rs @@ -21,10 +21,7 @@ pub async fn list( user: Extension, Path(project_id): Path, ) -> webserver::Result>> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); let list = sqlx::query! { "SELECT repo_ref, branch @@ -68,10 +65,7 @@ pub async fn add( Path(project_id): Path, Json(params): Json, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); sqlx::query! { "SELECT id FROM projects WHERE id = ? AND user_id = ?", @@ -108,10 +102,7 @@ pub async fn delete( Path(project_id): Path, Query(Delete { repo_ref }): Query, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); sqlx::query! { "DELETE FROM project_repos @@ -144,10 +135,7 @@ pub async fn put( Path(project_id): Path, Json(params): Json, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(webserver::no_user_id)? - .to_string(); + let user_id = "1".to_string(); sqlx::query! { "SELECT id FROM projects WHERE id = ? AND user_id = ?", diff --git a/server/bleep/src/webserver/query.rs b/server/bleep/src/webserver/query.rs index 498e6a80d2..dec4b8ab8a 100644 --- a/server/bleep/src/webserver/query.rs +++ b/server/bleep/src/webserver/query.rs @@ -16,5 +16,5 @@ pub(super) async fn handle( .query(&app) .await .map(json) - .map_err(super::Error::from) + .map_err(Error::from) } diff --git a/server/bleep/src/webserver/repos.rs b/server/bleep/src/webserver/repos.rs index 0e4929f2ce..bc29fbb992 100644 --- a/server/bleep/src/webserver/repos.rs +++ b/server/bleep/src/webserver/repos.rs @@ -168,7 +168,7 @@ impl Repo { last_update: origin.pushed_at.unwrap(), last_index: None, most_common_lang: None, - branch_filter: crate::repo::BranchFilterConfig::Select(vec![]), + branch_filter: BranchFilterConfig::Select(vec![]), file_filter: Default::default(), branches: vec![], } diff --git a/server/bleep/src/webserver/search.rs b/server/bleep/src/webserver/search.rs index 1c88cd8e15..a8d5eb4f2b 100644 --- a/server/bleep/src/webserver/search.rs +++ b/server/bleep/src/webserver/search.rs @@ -20,7 +20,7 @@ pub(super) async fn semantic_code( Ok(q) => semantic::execute::execute(semantic, q, args) .await .map(json) - .map_err(super::Error::from), + .map_err(Error::from), Err(err) => { error!(?err, "Couldn't parse query"); Err(Error::new(ErrorKind::UpstreamService, "error")) diff --git a/server/bleep/src/webserver/studio.rs b/server/bleep/src/webserver/studio.rs index d74e56c926..d7abad8acc 100644 --- a/server/bleep/src/webserver/studio.rs +++ b/server/bleep/src/webserver/studio.rs @@ -167,7 +167,7 @@ pub async fn get( Path((project_id, studio_id)): Path<(i64, i64)>, Query(params): Query, ) -> webserver::Result> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let snapshot_id = match params.snapshot_id { Some(id) => id, @@ -220,7 +220,7 @@ pub async fn patch( Path((project_id, studio_id)): Path<(i64, i64)>, Json(patch): Json, ) -> webserver::Result> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let mut transaction = app.sql.begin().await?; @@ -330,7 +330,7 @@ pub async fn delete( user: Extension, Path((project_id, studio_id)): Path<(i64, i64)>, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); sqlx::query!( "DELETE FROM studios @@ -365,7 +365,7 @@ pub async fn list( user: Extension, Path(project_id): Path, ) -> webserver::Result>> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let studios = sqlx::query!( "SELECT @@ -707,7 +707,7 @@ pub async fn generate( user: Extension, Path((_project_id, studio_id)): Path<(i64, i64)>, ) -> webserver::Result> + Send>>>> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let snapshot_id = latest_snapshot_id(studio_id, &*app.sql, &user_id).await?; @@ -935,7 +935,7 @@ pub async fn diff( user: Extension, Path((_project_id, studio_id)): Path<(i64, i64)>, ) -> webserver::Result> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let snapshot_id = latest_snapshot_id(studio_id, &*app.sql, &user_id).await?; @@ -991,7 +991,7 @@ pub async fn diff( let response = llm_gateway.chat(&messages, None).await?; let diff_chunks = diff::extract(&response)?.collect::>(); - let valid_chunks = futures::stream::iter(diff_chunks) + let valid_chunks = stream::iter(diff_chunks) .map(|mut chunk| { let app = (*app).clone(); let llm_context = llm_context.clone(); @@ -1250,7 +1250,7 @@ pub async fn diff_apply( Path((_project_id, studio_id)): Path<(i64, i64)>, diff: String, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let snapshot_id = latest_snapshot_id(studio_id, &*app.sql, &user_id).await?; @@ -1331,7 +1331,7 @@ pub async fn diff_apply( // Force a re-sync. for repo in dirty_repos { - let _ = crate::webserver::repos::sync( + let _ = webserver::repos::sync( Query(webserver::repos::RepoParams { repo, shallow: false, @@ -1352,7 +1352,7 @@ async fn populate_studio_name( user: Extension, studio_id: i64, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let snapshot_id = latest_snapshot_id(studio_id, &*app.sql, &user_id).await?; let needs_name = sqlx::query! { @@ -1421,7 +1421,7 @@ pub async fn import( ) -> webserver::Result { let mut transaction = app.sql.begin().await?; - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); let thread_id = params.thread_id.to_string(); @@ -1641,7 +1641,7 @@ pub async fn list_snapshots( user: Extension, Path((project_id, studio_id)): Path<(i64, i64)>, ) -> webserver::Result>> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); sqlx::query! { "SELECT ss.id as 'id!', ss.modified_at, ss.context, ss.doc_context, ss.messages @@ -1688,7 +1688,7 @@ pub async fn delete_snapshot( user: Extension, Path((project_id, studio_id, snapshot_id)): Path<(i64, i64, i64)>, ) -> webserver::Result<()> { - let user_id = user.username().ok_or_else(super::no_user_id)?.to_string(); + let user_id = "1".to_string(); sqlx::query! { "DELETE FROM studio_snapshots diff --git a/server/bleep/src/webserver/template.rs b/server/bleep/src/webserver/template.rs index 302fb43551..aa9d0a28aa 100644 --- a/server/bleep/src/webserver/template.rs +++ b/server/bleep/src/webserver/template.rs @@ -16,10 +16,7 @@ pub async fn create( user: Extension, params: Json, ) -> webserver::Result { - let user_id = user - .username() - .ok_or_else(|| super::Error::user("didn't have user ID"))? - .to_string(); + let user_id = "1"; let id = sqlx::query!( "INSERT INTO templates (name, content, user_id) VALUES (?, ?, ?)", @@ -47,10 +44,7 @@ pub async fn list( app: Extension, user: Extension, ) -> webserver::Result>> { - let user_id = user - .username() - .ok_or_else(|| super::Error::user("didn't have user ID"))? - .to_string(); + let user_id = "1"; let templates = sqlx::query_as!( Template, @@ -70,10 +64,7 @@ pub async fn get( user: Extension, Path(id): Path, ) -> webserver::Result> { - let user_id = user - .username() - .ok_or_else(|| super::Error::user("didn't have user ID"))? - .to_string(); + let user_id = "1"; let template = sqlx::query_as!( Template, @@ -102,10 +93,7 @@ pub async fn patch( Path(mut id): Path, Json(patch): Json, ) -> webserver::Result { - let user_id = user - .username() - .ok_or_else(|| super::Error::user("didn't have user ID"))? - .to_string(); + let user_id = "1"; let mut transaction = app.sql.begin().await?; @@ -165,10 +153,7 @@ pub async fn delete( user: Extension, Path(id): Path, ) -> webserver::Result<()> { - let user_id = user - .username() - .ok_or_else(|| super::Error::user("didn't have user ID"))? - .to_string(); + let user_id = "1"; sqlx::query!( "DELETE FROM templates WHERE id = ? AND user_id = ? RETURNING id",