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

Refactor db enums to be compatible with java #22

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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/presentation/http/dto/user_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
fn from(value: AllocatedTime) -> Self {
match value {
AllocatedTime::None => Self::None,
AllocatedTime::LessThanOneDay => Self::Lt1day,
AllocatedTime::OneToThreeDays => Self::_1to3days,
AllocatedTime::MoreThanThreeDays => Self::Gt3days,
AllocatedTime::LessThanOneDay => Self::LessThanOneDay,
AllocatedTime::OneToThreeDays => Self::OneToThreeDays,
AllocatedTime::MoreThanThreeDays => Self::GreaterThanThreeDays,

Check warning on line 18 in api/src/presentation/http/dto/user_profile.rs

View check run for this annotation

Codecov / codecov/patch

api/src/presentation/http/dto/user_profile.rs#L16-L18

Added lines #L16 - L18 were not covered by tests
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion api/tests/update_user_profile_it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ impl<'a> Test<'a> {
(String::from("Typescript"), 0)
]))
);
assert_eq!(user_profile.weekly_allocated_time, AllocatedTime::Lt1day);
assert_eq!(
user_profile.weekly_allocated_time,
AllocatedTime::LessThanOneDay
);
assert_eq!(user_profile.avatar_url, None);
assert_eq!(user_profile.cover.unwrap(), ProfileCover::Cyan);

Expand Down
6 changes: 3 additions & 3 deletions common/infrastructure/src/database/enums/allocated_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
#[ExistingTypePath = "crate::database::schema::sql_types::AllocatedTime"]
pub enum AllocatedTime {
None,
Lt1day,
_1to3days,
Gt3days,
LessThanOneDay,
OneToThreeDays,
GreaterThanThreeDays,
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, DbEnum)]
#[ExistingTypePath = "crate::database::schema::sql_types::ProjectVisibility"]
#[DbValueStyle = "SCREAMING_SNAKE_CASE"]
pub enum ProjectVisibility {
Public,
Private,
Expand Down
2 changes: 2 additions & 0 deletions migrations/2023-10-09-113924_refactor-enums-for-java/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT
1;
18 changes: 18 additions & 0 deletions migrations/2023-10-09-113924_refactor-enums-for-java/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ALTER TYPE public.project_visibility
RENAME VALUE 'public' TO 'PUBLIC';


ALTER TYPE public.project_visibility
RENAME VALUE 'private' TO 'PRIVATE';


ALTER TYPE public.allocated_time
RENAME VALUE 'lt1day' TO 'less_than_one_day';


ALTER TYPE public.allocated_time
RENAME VALUE '1to3days' TO 'one_to_three_days';


ALTER TYPE public.allocated_time
RENAME VALUE 'gt3days' TO 'greater_than_three_days';
Loading