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

chore: Refactor lastUpdated #2314

Merged
merged 1 commit into from
Sep 26, 2024
Merged

chore: Refactor lastUpdated #2314

merged 1 commit into from
Sep 26, 2024

Conversation

Chartman123
Copy link
Collaborator

This commit refactors the form creation and update logic in the ApiController class. It removes the unnecessary setting of the created and lastUpdated timestamps in the Form entity, as these values are now automatically set in the FormMapper class. This improves code readability and reduces redundancy.

The changes also include updates to the FormMapper class, where the insert and update methods now automatically set the created and lastUpdated timestamps respectively.

@Chartman123 Chartman123 added php PHP related ticket 2. developing Work in progress technical debt Technical issue labels Sep 9, 2024
@Chartman123 Chartman123 added this to the 4.3 milestone Sep 9, 2024
@Chartman123 Chartman123 linked an issue Sep 9, 2024 that may be closed by this pull request
@Chartman123 Chartman123 changed the title Refactor form creation and update logic Refactor lastUpdated Sep 9, 2024
@Chartman123 Chartman123 force-pushed the chore/refactor-lastUpdated branch 5 times, most recently from f42bf8a to bedcc05 Compare September 11, 2024 20:59
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 21.62162% with 29 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@b40ef76). Learn more about missing BASE report.
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2314   +/-   ##
=======================================
  Coverage        ?   36.25%           
  Complexity      ?     1011           
=======================================
  Files           ?       70           
  Lines           ?     3801           
  Branches        ?        0           
=======================================
  Hits            ?     1378           
  Misses          ?     2423           
  Partials        ?        0           

@Chartman123
Copy link
Collaborator Author

@susnux do you have any idea why I get an Error 500 as soon as I open the Forms app?

Type: Error
Code: 0
Message: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames
File: /srv/www/htdocs/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php
Line: 104

@Chartman123 Chartman123 force-pushed the chore/refactor-lastUpdated branch 2 times, most recently from 9aef8d5 to 2345d77 Compare September 13, 2024 22:29
@Chartman123 Chartman123 marked this pull request as ready for review September 13, 2024 23:04
@Chartman123 Chartman123 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 13, 2024
@Chartman123
Copy link
Collaborator Author

@susnux I was able to resolve my issue (thanks to @come-nc)

This can now be reviewed. I currently needed a little hack in the ApiControllerTest to make them pass. (state and lastUpdated don't have the expected values in line 499. null instead of 0 and 0 instead of 123456789).

@Chartman123 Chartman123 force-pushed the chore/refactor-lastUpdated branch 2 times, most recently from 8fcfb8a to 465c921 Compare September 21, 2024 09:37
@Chartman123 Chartman123 changed the title Refactor lastUpdated chore: Refactor lastUpdated Sep 24, 2024
@Koc Koc self-requested a review September 25, 2024 20:53
@Chartman123
Copy link
Collaborator Author

@Koc thanks for the approval. Do you perhaps have an idea how to fix the test in a better way? I'm no expert in tests 🙈😂

@Koc
Copy link
Collaborator

Koc commented Sep 25, 2024

Usually it is recommended to rely on Psr\Clock\ClockInterface instead of plain time() and use MockClock implementation in tests.

Another variant - you can mock native time() by defining mocked function inside same namespace.

But I think we can live with current approach.

@Chartman123
Copy link
Collaborator Author

Yes we can leave it for now and add a to-do comment. What bothers me the most is that the time() mocking worked before but doesn't anymore. Probably because the timestamp generation is now moved from the ApiController to the FormMapper

This commit refactors the form creation and update logic in the `ApiController` class. It removes the unnecessary setting of the `created` and `lastUpdated` timestamps in the `Form` entity, as these values are now automatically set in the `FormMapper` class. This improves code readability and reduces redundancy.

The changes also include updates to the `FormMapper` class, where the `insert` and `update` methods now automatically set the `created` and `lastUpdated` timestamps respectively.

Signed-off-by: Christian Hartmann <[email protected]>
@Chartman123 Chartman123 merged commit e290874 into main Sep 26, 2024
50 checks passed
@Chartman123 Chartman123 deleted the chore/refactor-lastUpdated branch September 26, 2024 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews php PHP related ticket technical debt Technical issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor lastUpdated handling
2 participants