Skip to content

Commit

Permalink
Refactor the purl_by's a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Crossley <[email protected]>
  • Loading branch information
jcrossley3 committed Jan 20, 2025
1 parent a4b12cd commit 9573043
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions modules/fundamental/src/purl/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,15 @@ impl PurlService {
connection: &C,
) -> Result<Option<PurlDetails>, Error> {
let canonical = CanonicalPurl::from(purl.clone());
let purl = qualified_purl::Entity::find()
match qualified_purl::Entity::find()
.filter(qualified_purl::Column::Purl.eq(canonical))
.one(connection)
.await?;
if let Some(purl) = purl {
Ok(Some(
.await?
{
Some(purl) => Ok(Some(
PurlDetails::from_entity(None, None, &purl, deprecation, connection).await?,
))
} else {
Ok(None)
)),
None => Ok(None),
}
}

Expand All @@ -257,16 +256,14 @@ impl PurlService {
deprecation: Deprecation,
connection: &C,
) -> Result<Option<PurlDetails>, Error> {
if let Some(qualified_package) = qualified_purl::Entity::find_by_id(*purl_uuid)
match qualified_purl::Entity::find_by_id(*purl_uuid)
.one(connection)
.await?
{
Ok(Some(
PurlDetails::from_entity(None, None, &qualified_package, deprecation, connection)
.await?,
))
} else {
Ok(None)
Some(pkg) => Ok(Some(
PurlDetails::from_entity(None, None, &pkg, deprecation, connection).await?,
)),
None => Ok(None),
}
}

Expand Down

0 comments on commit 9573043

Please sign in to comment.