Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature/324_impleme…
Browse files Browse the repository at this point in the history
…nt_update_locations' into feature/324_implement_update_locations
  • Loading branch information
brendan-oconnell committed Sep 25, 2024
2 parents 92e2085 + 8155b1c commit 15553fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
11 changes: 3 additions & 8 deletions thoth-api/src/graphql/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,8 @@ impl MutationRoot {
#[graphql(description = "Update an existing location with the specified values")]
fn update_location(
context: &Context,
#[graphql(description = "Values to apply to existing location")] data: PatchLocation,
#[graphql(description = "Values to apply to existing location")]
data: PatchLocation,
) -> FieldResult<Location> {
context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?;

Expand Down Expand Up @@ -2020,13 +2021,7 @@ impl MutationRoot {
};

location
.update_canonical_location(
&context.db,
data,
&old_canonical_location,
old_canonical_location.location_id,
&account_id,
)
.update_canonical_location(&context.db, data, &old_canonical_location, old_canonical_location.location_id, &account_id)
.map_err(|e| e.into())
}
}
Expand Down
7 changes: 5 additions & 2 deletions thoth-api/src/model/location/crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ impl Location {
}

impl PatchLocation {
pub fn get_canonical_location(&self, db: &crate::db::PgPool) -> ThothResult<Location> {
pub fn get_canonical_location(
&self,
db: &crate::db::PgPool
) -> ThothResult<Location> {
let mut connection = db.get()?;
let canonical_location = crate::schema::location::table
.filter(crate::schema::location::publication_id.eq(self.publication_id))
Expand All @@ -223,7 +226,7 @@ impl PatchLocation {
.expect("Error loading canonical location for publication");
Ok(canonical_location)
}

pub fn canonical_record_complete(&self, db: &crate::db::PgPool) -> ThothResult<()> {
location_canonical_record_complete(
self.publication_id,
Expand Down

0 comments on commit 15553fb

Please sign in to comment.