feat: add endpoint to aid with db migration
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
244abd64aa
commit
2b4c1e7976
|
@ -855,6 +855,17 @@ pub async fn get_info(state: web::Data<State>) -> Result<HttpResponse, Error> {
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/api/migration/user-entries")]
|
||||||
|
pub async fn get_user_entries(state: web::Data<State>) -> Result<HttpResponse, Error> {
|
||||||
|
let connection = state.upend.connection().map_err(ErrorInternalServerError)?;
|
||||||
|
|
||||||
|
let result = web::block(move || connection.get_explicit_entries())
|
||||||
|
.await?
|
||||||
|
.map_err(ErrorInternalServerError)?;
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(result.as_hash().map_err(ErrorInternalServerError)?))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum ExternalFetchError {
|
enum ExternalFetchError {
|
||||||
Status(anyhow::Error),
|
Status(anyhow::Error),
|
||||||
|
|
|
@ -63,7 +63,8 @@ where
|
||||||
.service(routes::vault_stats)
|
.service(routes::vault_stats)
|
||||||
.service(routes::store_stats)
|
.service(routes::store_stats)
|
||||||
.service(routes::get_jobs)
|
.service(routes::get_jobs)
|
||||||
.service(routes::get_info);
|
.service(routes::get_info)
|
||||||
|
.service(routes::get_user_entries);
|
||||||
|
|
||||||
if let Some(ui_path) = ui_path {
|
if let Some(ui_path) = ui_path {
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -409,6 +409,26 @@ impl UpEndConnection {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
pub fn get_explicit_entries(&self) -> Result<Vec<Entry>> {
|
||||||
|
use crate::database::inner::schema::data::dsl::*;
|
||||||
|
let _lock = self.lock.read().unwrap();
|
||||||
|
let conn = self.pool.get()?;
|
||||||
|
|
||||||
|
let result: Vec<models::Entry> = data
|
||||||
|
.filter(
|
||||||
|
provenance
|
||||||
|
.like("API%")
|
||||||
|
.and(provenance.not_like("%IMPLICIT%")),
|
||||||
|
)
|
||||||
|
.load(&conn)?;
|
||||||
|
|
||||||
|
Ok(result
|
||||||
|
.iter()
|
||||||
|
.map(Entry::try_from)
|
||||||
|
.collect::<Result<Vec<Entry>>>()?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue