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

Implementation/45801 api with subset representer #12107

Merged
merged 86 commits into from Mar 1, 2023

Conversation

ulferts
Copy link
Contributor

@ulferts ulferts commented Feb 16, 2023

Builds on #11783 which in turn builds on #11678 and contains their commits.

The goal of this PR is to:

  • have the attributesByTimestamp property of the WorkPackage resource rendered according to the prototypical readout in Baseline-comparison API #11783 (https://community.openproject.org/wp/46263)
    • Only properties that have changed compared to the baseline are listed.
    • Only supported properties are listed.
    • The properties are listed same as they are listed in the work package resources directly. That is e.g. that a linked resource like "assignee" is in the _links section.
  • Optimize the loading of data from the database and prepare that data in a way that the impact of having comparison timestamps when rendering a collection of work packages (e.g. api/v3/work_packages?timestamps=2023-01-31T00:00:00Z,PT0S) is minimized. To that end, the eager loading wrapper needs to be adapted. (https://community.openproject.org/wp/46262)

to decorate work packages with historic attributes and meta information.

#11783
…now` is queried

because this is the default case when no timestamp is given

#11783
…iven

Otherwise, there are not filters to match and this field is meaningless.

#11783
which should be plural because there can be several filters in the query.

#11783
Copy link
Collaborator

@fiedl fiedl left a comment

Choose a reason for hiding this comment

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

Thanks!

app/models/journable/with_historic_attributes.rb Outdated Show resolved Hide resolved
app/models/journable/with_historic_attributes.rb Outdated Show resolved Hide resolved
app/models/journable/with_historic_attributes.rb Outdated Show resolved Hide resolved
spec/models/journable/with_historic_attributes_spec.rb Outdated Show resolved Hide resolved
spec/models/journable/with_historic_attributes_spec.rb Outdated Show resolved Hide resolved
spec/models/timestamp_spec.rb Outdated Show resolved Hide resolved

it_behaves_like 'transforms' do
let(:params) { { timestamps: "-1y, now" } }
let(:expected) { { timestamps: [Timestamp.new("P-1Y"), Timestamp.parse("P-0Y")] } }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, this is why you delegated the Timestamp#hash method :) 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it for the memoization where a timestamp is the hash key

I did not know that was necessary before stumbling over this. With it I can do

pry(main)> { Timestamp.now => 1}[Timestamp.now]
=> 1

Without it it would be

pry(main)> { Timestamp.now => 1}[Timestamp.now]
=> nil

@ulferts
Copy link
Contributor Author

ulferts commented Mar 1, 2023

@fiedl I think I addressed or commented on all your remarks. Could you please take another look?

@fiedl
Copy link
Collaborator

fiedl commented Mar 1, 2023

Thanks, very nice!

@ulferts ulferts marked this pull request as ready for review March 1, 2023 19:41
@ulferts ulferts requested a review from a team as a code owner March 1, 2023 19:41
@ulferts ulferts merged commit b8507e2 into dev Mar 1, 2023
@ulferts ulferts deleted the implementation/45801-api-with-subset-representer branch March 1, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants