Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving contribution type to upper case #32

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/models/work_items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
repo_id,
number: number.into(),
id: id.to_string(),
type_: ContributionType::Issue,
type_: ContributionType::ISSUE,

Check warning on line 48 in api/src/models/work_items/mod.rs

View check run for this annotation

Codecov / codecov/patch

api/src/models/work_items/mod.rs#L48

Added line #L48 was not covered by tests
project_id,
recipient_id,
},
Expand All @@ -58,7 +58,7 @@
repo_id,
number: number.into(),
id: id.to_string(),
type_: ContributionType::CodeReview,
type_: ContributionType::CODE_REVIEW,

Check warning on line 61 in api/src/models/work_items/mod.rs

View check run for this annotation

Codecov / codecov/patch

api/src/models/work_items/mod.rs#L61

Added line #L61 was not covered by tests
project_id,
recipient_id,
},
Expand All @@ -71,7 +71,7 @@
repo_id,
number: number.into(),
id: id.to_string(),
type_: ContributionType::PullRequest,
type_: ContributionType::PULL_REQUEST,

Check warning on line 74 in api/src/models/work_items/mod.rs

View check run for this annotation

Codecov / codecov/patch

api/src/models/work_items/mod.rs#L74

Added line #L74 was not covered by tests
project_id,
recipient_id,
},
Expand Down
14 changes: 8 additions & 6 deletions common/infrastructure/src/database/enums/contribution_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

#[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,
PullRequest,
CodeReview,
ISSUE,
PULL_REQUEST,
CODE_REVIEW,
}

impl Display for ContributionType {
Expand All @@ -17,9 +19,9 @@
f,
"{}",
match self {
ContributionType::Issue => "ISSUE",
ContributionType::PullRequest => "PULL_REQUEST",
ContributionType::CodeReview => "CODE_REVIEW",
ContributionType::ISSUE => "ISSUE",

Check warning on line 22 in common/infrastructure/src/database/enums/contribution_type.rs

View check run for this annotation

Codecov / codecov/patch

common/infrastructure/src/database/enums/contribution_type.rs#L22

Added line #L22 was not covered by tests
ContributionType::PULL_REQUEST => "PULL_REQUEST",
ContributionType::CODE_REVIEW => "CODE_REVIEW",

Check warning on line 24 in common/infrastructure/src/database/enums/contribution_type.rs

View check run for this annotation

Codecov / codecov/patch

common/infrastructure/src/database/enums/contribution_type.rs#L24

Added line #L24 was not covered by tests
}
)
}
Expand Down
8 changes: 4 additions & 4 deletions github-indexer/src/models/contributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
user_id,
type_,
details_id: match type_ {
ContributionType::Issue => DetailsId::Issue(details_id.parse::<u64>()?.into()),
ContributionType::PullRequest =>
ContributionType::ISSUE => DetailsId::Issue(details_id.parse::<u64>()?.into()),

Check warning on line 110 in github-indexer/src/models/contributions/mod.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/mod.rs#L110

Added line #L110 was not covered by tests
ContributionType::PULL_REQUEST =>
DetailsId::PullRequest(details_id.parse::<u64>()?.into()),
ContributionType::CodeReview => DetailsId::CodeReview(details_id.parse()?),
ContributionType::CODE_REVIEW => DetailsId::CodeReview(details_id.parse()?),

Check warning on line 113 in github-indexer/src/models/contributions/mod.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/mod.rs#L113

Added line #L113 was not covered by tests
},
status,
created_at,
Expand All @@ -131,7 +131,7 @@
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(),
Expand Down
30 changes: 15 additions & 15 deletions github-indexer/src/models/contributions/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
.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 {

Check warning on line 40 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L36-L40

Added lines #L36 - L40 were not covered by tests
GithubIssueStatus::Completed => ContributionStatus::Complete,
GithubIssueStatus::Open => ContributionStatus::InProgress,
GithubIssueStatus::Cancelled => ContributionStatus::Canceled,
},
issue.created_at,
issue.closed_at,
issue.created_at,
issue.closed_at,

Check warning on line 46 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L45-L46

Added lines #L45 - L46 were not covered by tests
)
})
.collect();
Expand All @@ -53,9 +53,9 @@
connection
.transaction(|connection| {
delete_all_contributions_for_details(
connection,
DetailsId::from(issue.id),
ContributionType::Issue,
connection,
DetailsId::from(issue.id),
ContributionType::ISSUE,

Check warning on line 58 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L56-L58

Added lines #L56 - L58 were not covered by tests
)?;

diesel::insert_into(contributions::table)
Expand Down Expand Up @@ -99,7 +99,7 @@
Contribution::new(
pull_request.inner.repo_id,
commit.author_id,
ContributionType::PullRequest,
ContributionType::PULL_REQUEST,

Check warning on line 102 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L102

Added line #L102 was not covered by tests
pull_request.inner.id.into(),
pull_request.inner.status.into(),
pull_request.inner.created_at,
Expand All @@ -109,7 +109,7 @@
.chain(std::iter::once(Contribution::new(
pull_request.inner.repo_id,
pull_request.inner.author_id,
ContributionType::PullRequest,
ContributionType::PULL_REQUEST,

Check warning on line 112 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L112

Added line #L112 was not covered by tests
pull_request.inner.id.into(),
pull_request.inner.status.into(),
pull_request.inner.created_at,
Expand All @@ -124,7 +124,7 @@
delete_all_contributions_for_details(
connection,
DetailsId::from(pull_request.inner.id),
ContributionType::PullRequest,
ContributionType::PULL_REQUEST,

Check warning on line 127 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L127

Added line #L127 was not covered by tests
)?;

diesel::insert_into(contributions::table)
Expand All @@ -145,7 +145,7 @@
) -> 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))

Check warning on line 148 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L148

Added line #L148 was not covered by tests
.set((
contributions::status.eq::<ContributionStatus>(pull_request.inner.status.into()),
contributions::closed_at.eq(pull_request.inner.closed_at),
Expand All @@ -169,7 +169,7 @@
let contribution = Contribution::new(
pull_request.inner.repo_id,
review.reviewer_id,
ContributionType::CodeReview,
ContributionType::CODE_REVIEW,

Check warning on line 172 in github-indexer/src/models/contributions/repository.rs

View check run for this annotation

Codecov / codecov/patch

github-indexer/src/models/contributions/repository.rs#L172

Added line #L172 was not covered by tests
review
.id
.parse::<GithubCodeReviewId>()
Expand Down
24 changes: 12 additions & 12 deletions github-indexer/tests/github_indexing_it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Loading