From c70cd9cb5a03142ef64ff723554d657b0ff50f86 Mon Sep 17 00:00:00 2001 From: PierreOucif Date: Tue, 28 Nov 2023 19:08:26 +0100 Subject: [PATCH 1/2] Moving contribution type to upper case --- api/src/models/work_items/mod.rs | 6 ++-- .../src/database/enums/contribution_type.rs | 12 ++++---- .../src/models/contributions/mod.rs | 8 ++--- .../src/models/contributions/repository.rs | 30 +++++++++---------- github-indexer/tests/github_indexing_it.rs | 24 +++++++-------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/api/src/models/work_items/mod.rs b/api/src/models/work_items/mod.rs index 1cc944ca2d..3883879f57 100644 --- a/api/src/models/work_items/mod.rs +++ b/api/src/models/work_items/mod.rs @@ -45,7 +45,7 @@ impl From<(ProjectId, PaymentId, GithubUserId, PaymentWorkItem)> for WorkItem { repo_id, number: number.into(), id: id.to_string(), - type_: ContributionType::Issue, + type_: ContributionType::ISSUE, project_id, recipient_id, }, @@ -58,7 +58,7 @@ impl From<(ProjectId, PaymentId, GithubUserId, PaymentWorkItem)> for WorkItem { repo_id, number: number.into(), id: id.to_string(), - type_: ContributionType::CodeReview, + type_: ContributionType::CODE_REVIEW, project_id, recipient_id, }, @@ -71,7 +71,7 @@ impl From<(ProjectId, PaymentId, GithubUserId, PaymentWorkItem)> for WorkItem { repo_id, number: number.into(), id: id.to_string(), - type_: ContributionType::PullRequest, + type_: ContributionType::PULL_REQUEST, project_id, recipient_id, }, diff --git a/common/infrastructure/src/database/enums/contribution_type.rs b/common/infrastructure/src/database/enums/contribution_type.rs index c617ad4d65..b7a50fca93 100644 --- a/common/infrastructure/src/database/enums/contribution_type.rs +++ b/common/infrastructure/src/database/enums/contribution_type.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Hash, Deserialize, DbEnum)] #[ExistingTypePath = "crate::database::schema::sql_types::ContributionType"] pub enum ContributionType { - Issue, - PullRequest, - CodeReview, + ISSUE, + PULL_REQUEST, + CODE_REVIEW, } impl Display for ContributionType { @@ -17,9 +17,9 @@ impl Display for ContributionType { f, "{}", match self { - ContributionType::Issue => "ISSUE", - ContributionType::PullRequest => "PULL_REQUEST", - ContributionType::CodeReview => "CODE_REVIEW", + ContributionType::ISSUE => "ISSUE", + ContributionType::PULL_REQUEST => "PULL_REQUEST", + ContributionType::CODE_REVIEW => "CODE_REVIEW", } ) } diff --git a/github-indexer/src/models/contributions/mod.rs b/github-indexer/src/models/contributions/mod.rs index a6064df17f..7ffebc1157 100644 --- a/github-indexer/src/models/contributions/mod.rs +++ b/github-indexer/src/models/contributions/mod.rs @@ -107,10 +107,10 @@ where user_id, type_, details_id: match type_ { - ContributionType::Issue => DetailsId::Issue(details_id.parse::()?.into()), - ContributionType::PullRequest => + ContributionType::ISSUE => DetailsId::Issue(details_id.parse::()?.into()), + ContributionType::PULL_REQUEST => DetailsId::PullRequest(details_id.parse::()?.into()), - ContributionType::CodeReview => DetailsId::CodeReview(details_id.parse()?), + ContributionType::CODE_REVIEW => DetailsId::CodeReview(details_id.parse()?), }, status, created_at, @@ -131,7 +131,7 @@ mod tests { let contribution = Contribution::new( GithubRepoId::from(485838614_u64), GithubUserId::from(99273364_u64), - ContributionType::PullRequest, + ContributionType::PULL_REQUEST, DetailsId::PullRequest(1111346398_u64.into()), ContributionStatus::InProgress, "2023-09-06T00:00:00".parse().unwrap(), diff --git a/github-indexer/src/models/contributions/repository.rs b/github-indexer/src/models/contributions/repository.rs index 221071765b..99074ada5f 100644 --- a/github-indexer/src/models/contributions/repository.rs +++ b/github-indexer/src/models/contributions/repository.rs @@ -33,17 +33,17 @@ impl Repository for dbclient::Client { .into_iter() .map(|assignee| { Contribution::new( - issue.repo_id, - assignee, - ContributionType::Issue, - issue.id.into(), - match issue.status { + issue.repo_id, + assignee, + ContributionType::ISSUE, + issue.id.into(), + match issue.status { GithubIssueStatus::Completed => ContributionStatus::Complete, GithubIssueStatus::Open => ContributionStatus::InProgress, GithubIssueStatus::Cancelled => ContributionStatus::Canceled, }, - issue.created_at, - issue.closed_at, + issue.created_at, + issue.closed_at, ) }) .collect(); @@ -53,9 +53,9 @@ impl Repository for dbclient::Client { connection .transaction(|connection| { delete_all_contributions_for_details( - connection, - DetailsId::from(issue.id), - ContributionType::Issue, + connection, + DetailsId::from(issue.id), + ContributionType::ISSUE, )?; diesel::insert_into(contributions::table) @@ -99,7 +99,7 @@ fn refresh_contributions_from_commits( Contribution::new( pull_request.inner.repo_id, commit.author_id, - ContributionType::PullRequest, + ContributionType::PULL_REQUEST, pull_request.inner.id.into(), pull_request.inner.status.into(), pull_request.inner.created_at, @@ -109,7 +109,7 @@ fn refresh_contributions_from_commits( .chain(std::iter::once(Contribution::new( pull_request.inner.repo_id, pull_request.inner.author_id, - ContributionType::PullRequest, + ContributionType::PULL_REQUEST, pull_request.inner.id.into(), pull_request.inner.status.into(), pull_request.inner.created_at, @@ -124,7 +124,7 @@ fn refresh_contributions_from_commits( delete_all_contributions_for_details( connection, DetailsId::from(pull_request.inner.id), - ContributionType::PullRequest, + ContributionType::PULL_REQUEST, )?; diesel::insert_into(contributions::table) @@ -145,7 +145,7 @@ fn update_contributions_status( ) -> Result<()> { diesel::update(contributions::table) .filter(contributions::details_id.eq(DetailsId::from(pull_request.inner.id))) - .filter(contributions::type_.eq(ContributionType::PullRequest)) + .filter(contributions::type_.eq(ContributionType::PULL_REQUEST)) .set(( contributions::status.eq::(pull_request.inner.status.into()), contributions::closed_at.eq(pull_request.inner.closed_at), @@ -169,7 +169,7 @@ fn refresh_contributions_from_reviews( let contribution = Contribution::new( pull_request.inner.repo_id, review.reviewer_id, - ContributionType::CodeReview, + ContributionType::CODE_REVIEW, review .id .parse::() diff --git a/github-indexer/tests/github_indexing_it.rs b/github-indexer/tests/github_indexing_it.rs index b0bf6f7900..9001220bcb 100644 --- a/github-indexer/tests/github_indexing_it.rs +++ b/github-indexer/tests/github_indexing_it.rs @@ -199,7 +199,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::Issue); + assert_eq!(contribution.type_, ContributionType::ISSUE); assert_eq!(contribution.user_id, users::ofux().id); assert_eq!( contribution.details_id, @@ -212,7 +212,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::ofux().id); assert_eq!( contribution.details_id, @@ -223,7 +223,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::anthony().id); assert_eq!( contribution.details_id, @@ -236,7 +236,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::ofux().id); assert_eq!( contribution.details_id, @@ -248,7 +248,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::alex().id); assert_eq!( contribution.details_id, @@ -262,7 +262,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::stan().id); assert_eq!( contribution.details_id, @@ -275,7 +275,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::PullRequest); + assert_eq!(contribution.type_, ContributionType::PULL_REQUEST); assert_eq!(contribution.user_id, users::anthony().id); assert_eq!( contribution.details_id, @@ -288,7 +288,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::CodeReview); + assert_eq!(contribution.type_, ContributionType::CODE_REVIEW); assert_eq!(contribution.user_id, users::ofux().id); assert_eq!(contribution.status, ContributionStatus::Complete); } @@ -297,7 +297,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::CodeReview); + assert_eq!(contribution.type_, ContributionType::CODE_REVIEW); assert_eq!(contribution.user_id, users::anthony().id); assert_eq!(contribution.status, ContributionStatus::InProgress); } @@ -306,7 +306,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::CodeReview); + assert_eq!(contribution.type_, ContributionType::CODE_REVIEW); assert_eq!(contribution.user_id, users::alex().id); assert_eq!(contribution.status, ContributionStatus::InProgress); } @@ -315,7 +315,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::CodeReview); + assert_eq!(contribution.type_, ContributionType::CODE_REVIEW); assert_eq!(contribution.user_id, users::anthony().id); assert_eq!(contribution.status, ContributionStatus::Complete); } @@ -324,7 +324,7 @@ impl<'a> Test<'a> { { let contribution = contributions.pop().unwrap(); assert_eq!(contribution.repo_id, repos::marketplace().id); - assert_eq!(contribution.type_, ContributionType::CodeReview); + assert_eq!(contribution.type_, ContributionType::CODE_REVIEW); assert_eq!(contribution.user_id, users::anthony().id); assert_eq!(contribution.status, ContributionStatus::InProgress); } From 8dc1e5fa455655d32dc0b86ef007d19631a977c2 Mon Sep 17 00:00:00 2001 From: PierreOucif Date: Tue, 28 Nov 2023 19:12:23 +0100 Subject: [PATCH 2/2] Testing to disable CI linters --- common/infrastructure/src/database/enums/contribution_type.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/infrastructure/src/database/enums/contribution_type.rs b/common/infrastructure/src/database/enums/contribution_type.rs index b7a50fca93..df66fe3674 100644 --- a/common/infrastructure/src/database/enums/contribution_type.rs +++ b/common/infrastructure/src/database/enums/contribution_type.rs @@ -5,6 +5,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Hash, Deserialize, DbEnum)] #[ExistingTypePath = "crate::database::schema::sql_types::ContributionType"] +#[allow(clippy::wrong_self_convention)] +#[rustfmt::skip] pub enum ContributionType { ISSUE, PULL_REQUEST,