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: user mapper #1795

Merged
merged 8 commits into from
Jun 16, 2023
Merged

refactor: user mapper #1795

merged 8 commits into from
Jun 16, 2023

Conversation

typfel
Copy link
Member

@typfel typfel commented Jun 13, 2023


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

  1. There's code duplication in the user mapper with several variations of the same mapping.
  2. Some mapping function are not used at all
  3. The naming is inconsistent

Solutions

  1. Normalise the mapping functions
  2. Delete unused mapping functions
  3. Use naming based on actual classes/types

Notes

Should we merge PublicUserMapping and UserMapping into one?


PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 13, 2023

Unit Test Results

   271 files   - 103     271 suites   - 103   10s ⏱️ - 1m 10s
1 371 tests  - 616  1 340 ✔️  - 565  31 💤  - 51  0 ±0 

Results for commit 6ce1085. ± Comparison against base commit e353d3d.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2023

Codecov Report

Merging #1795 (6ce1085) into develop (e353d3d) will decrease coverage by 0.05%.
The diff coverage is 52.32%.

@@              Coverage Diff              @@
##             develop    #1795      +/-   ##
=============================================
- Coverage      53.53%   53.48%   -0.05%     
+ Complexity      1514     1511       -3     
=============================================
  Files            960      960              
  Lines          35763    35740      -23     
  Branches        3171     3164       -7     
=============================================
- Hits           19144    19114      -30     
- Misses         15343    15366      +23     
+ Partials        1276     1260      -16     

Comment on lines 41 to 55
// @Test
// fun givenUserProfileDTOAndUserTypeEntity_whenMappingFromApiResponse_thenDaoModelIsReturned() = runTest {
// // Given
// val givenResponse = TestUser.USER_PROFILE_DTO
// val givenUserTypeEntity = UserTypeEntity.EXTERNAL
// val expectedResult = TestUser.ENTITY.copy(
// phone = null, // UserProfileDTO doesn't contain the phone
// connectionStatus = ConnectionEntity.State.NOT_CONNECTED // UserProfileDTO doesn't contain the connection status
// )
// val (_, userMapper) = Arrangement().arrange()
// // When
// val result = userMapper.fromApiModelWithUserTypeEntityToDaoModel(givenResponse, givenUserTypeEntity)
// // Then
// assertEquals(expectedResult, result)
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to delete it after deleting this mapping function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to resurrect it since test coverage of the other function was completely missing.

@typfel typfel requested a review from vitorhugods June 13, 2023 10:47
Copy link
Contributor

@Garzas Garzas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, but can we make it as extension like we did with IdMappers? It will be easier to know that we are not duplicating mappers? 😄

@typfel
Copy link
Member Author

typfel commented Jun 13, 2023

Looking good, but can we make it as extension like we did with IdMappers? It will be easier to know that we are not duplicating mappers? 😄

We've agreed to do it like that for all mappers going forward? I'm not doing it in this PR though, it would be a follow up PR then.

@typfel typfel requested a review from Garzas June 13, 2023 15:32
Copy link
Member

@vitorhugods vitorhugods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny suggestions to remove comments

typfel and others added 2 commits June 16, 2023 11:57
Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Vitor Hugo Schwaab <[email protected]>
@typfel typfel added this pull request to the merge queue Jun 16, 2023
Merged via the queue into develop with commit ed3bdbb Jun 16, 2023
@typfel typfel deleted the refactor/user-mapper branch June 16, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants