Skip to content

Commit 22a33be

Browse files
committed
fixes
1 parent 5f5d62c commit 22a33be

File tree

7 files changed

+22
-9
lines changed

7 files changed

+22
-9
lines changed

lib/bencher_comment/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88

99
use bencher_json::{
1010
AlertUuid, BenchmarkSlug, BranchSlug, JsonAlert, JsonBenchmark, JsonBoundary, JsonMeasure,
11-
JsonPerfQuery, JsonReport, MeasureSlug, ReportUuid, ResourceName, Slug, TestbedSlug,
11+
JsonPerfQuery, JsonReport, MeasureSlug, ProjectSlug, ReportUuid, ResourceName, TestbedSlug,
1212
ThresholdUuid, Units,
1313
project::{
1414
alert::AlertStatus,
@@ -27,7 +27,7 @@ const EMPTY_CELL: &str = "<td></td>";
2727

2828
pub struct ReportComment {
2929
console_url: Url,
30-
project_slug: Slug,
30+
project_slug: ProjectSlug,
3131
public_links: bool,
3232
multiple_iterations: bool,
3333
benchmark_count: usize,

lib/bencher_json/src/organization/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl From<UserUuid> for OrganizationUuid {
3232

3333
impl From<ProjectSlug> for OrganizationSlug {
3434
fn from(slug: ProjectSlug) -> Self {
35-
Self(Slug::from(slug))
35+
Self(slug.into())
3636
}
3737
}
3838

lib/bencher_json/src/typed_slug.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ macro_rules! typed_slug {
4444
}
4545
}
4646

47+
impl AsRef<str> for $slug {
48+
fn as_ref(&self) -> &str {
49+
self.0.as_ref()
50+
}
51+
}
52+
4753
$crate::typed_db::typed_db!($slug);
4854
};
4955
($slug:ident, $name:ident) => {

lib/bencher_schema/src/model/organization/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ impl QueryOrganization {
9494
project_slug: &ProjectSlug,
9595
) -> Result<Self, HttpError> {
9696
// The project organization should be created with the project's slug.
97-
if let Ok(query_organization) =
98-
Self::from_resource_id(conn_lock!(context), &project_slug.clone().into())
99-
{
97+
if let Ok(query_organization) = Self::from_resource_id(
98+
conn_lock!(context),
99+
&OrganizationSlug::from(project_slug.clone()).into(),
100+
) {
100101
// If the project is part of an organization that is claimed,
101102
// then the project can not have anonymous reports.
102103
return if query_organization.is_claimed(conn_lock!(context))? {

lib/bencher_schema/src/model/project/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl InsertProject {
592592
visibility,
593593
} = project;
594594
let slug = ok_slug!(conn, &name, slug.map(Into::into), project, QueryProject);
595-
Self::new(organization.id, name, slug, url, visibility)
595+
Self::new(organization.id, name, slug.into(), url, visibility)
596596
}
597597

598598
fn from_organization(

lib/bencher_schema/src/model/user/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bencher_json::{
2-
DateTime, JsonNewToken, JsonToken, Jwt, ResourceId, ResourceName, TokenUuid,
2+
DateTime, JsonNewToken, JsonToken, Jwt, ResourceId, ResourceName, TokenUuid, UserResourceId,
33
user::token::JsonUpdateToken,
44
};
55
use bencher_token::TokenKey;
@@ -134,7 +134,7 @@ impl InsertToken {
134134
conn: &mut DbConnection,
135135
rbac: &Rbac,
136136
token_key: &TokenKey,
137-
user: &ResourceId,
137+
user: &UserResourceId,
138138
token: JsonNewToken,
139139
auth_user: &AuthUser,
140140
) -> Result<Self, HttpError> {

lib/bencher_valid/src/resource_id.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ pub enum ResourceId<U, S> {
1818
Slug(S),
1919
}
2020

21+
impl<U, S> From<S> for ResourceId<U, S> {
22+
fn from(slug: S) -> Self {
23+
Self::Slug(slug)
24+
}
25+
}
26+
2127
#[cfg(feature = "schema")]
2228
impl<U, S> JsonSchema for ResourceId<U, S>
2329
where

0 commit comments

Comments
 (0)