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

Feat/get latest status extensionmethod #270

Merged
merged 5 commits into from
Sep 16, 2024

Conversation

CelineTrammi
Copy link
Contributor

@CelineTrammi CelineTrammi commented Sep 13, 2024

Add extension methods for Correspondence and Attachment

Description

Previously there was a lot of duplicate code regarding getting the latest status for correspondence and attachment. This was often done using standard filtering on date. However, in the statusRepository classes there are methods of retrieving them there. As each of these calls are asynchronous, another approach is to add extension methods. Extension methods helps with removing a lot of the duplicate code and is arguably easier to read and comprehend compared.

Additions:

  • CorrespondenceExtensions.cs
  • AttachmentExtensions.cs

I considered creating extensions for the Status objects instead of the whole correspondence and attachment objects, and possibly returning CorrespondenceStatus (as opposed to CorrespondenceStatusEntity). However after looking at the code, retrieving latest status always uses the correspondence/attachment (meaning they are always available), and latest status is typically used with the actual Status, but also the fields StatusChanged and StatusText

Deletions:

  • GetLatestStatusByCorrespondenceId
  • GetLatestStatusByAttachmentId

As these are not used, they have been temporarily removed. There may come a time where we only want the latest status and no other fields.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@CelineTrammi CelineTrammi marked this pull request as ready for review September 16, 2024 06:34
Copy link
Collaborator

@Ceredron Ceredron left a comment

Choose a reason for hiding this comment

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

Great use of extension methods!

@CelineTrammi CelineTrammi merged commit 3dc4f70 into main Sep 16, 2024
4 checks passed
@CelineTrammi CelineTrammi deleted the feat/get-latestStatus-extensionmethod branch September 16, 2024 07:51
@CelineTrammi CelineTrammi added kind/feature kind/enhancement Improving existing feature and removed kind/feature labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improving existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants