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

[Instrument] Make instrument data non-static #6868

Merged
merged 5 commits into from
Nov 20, 2020

Conversation

driusan
Copy link
Collaborator

@driusan driusan commented Jul 27, 2020

NDB_BVL_Instrument has an.. unusual.. way of dealing with instrument
data. Rather than having a class method for getting the data, there's
a static method which takes an instrument as a parameter. The result
is that data can not be cached in the object and needs to be continuously
re-loaded from the database every time if it's needed multiple times in
the same request. (For instance, calling getFieldValue for different fields
in a script.)

This adds a normal getter and caches the results in the object, deprecating
the old static loadInstanceData and its inexplicable behaviour.

@driusan driusan added Blocking PR should be prioritized because it is blocking the progress of another task Meta PR does something that organizes, upgrades, or manages the functionality of the codebase labels Jul 27, 2020
@ridz1208 ridz1208 self-assigned this Aug 18, 2020
@laemtl laemtl self-assigned this Nov 20, 2020
@laemtl
Copy link
Contributor

laemtl commented Nov 20, 2020

@driusan
Copy link
Collaborator Author

driusan commented Nov 20, 2020

Good catch, I missed that one.. updated it.

@laemtl laemtl added the Passed manual tests PR has been successfully tested by at least one peer label Nov 20, 2020
@laemtl laemtl self-requested a review November 20, 2020 19:51
Copy link
Contributor

@laemtl laemtl left a comment

Choose a reason for hiding this comment

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

Checked and caching system works and instruments load without any issues.

NDB_BVL_Instrument has an.. unusual.. way of dealing with instrument
data. Rather than having a class method for getting the data, there's
a static method which takes an instrument as a parameter. The result
is that data can not be cached in the object and needs to be continuously
re-loaded from the database every time if it's needed multiple times in
the same request. (For instance, calling getFieldValue for different fields
in a script.)

This adds a normal getter and caches the results in the object, deprecating
the old static loadInstanceData and its inexplicable behaviour.
@laemtl
Copy link
Contributor

laemtl commented Nov 20, 2020

One last thing! Phan is throwing some errors:

test/unittests/NDB_BVL_Instrument_Test.php:1140 PhanDeprecatedFunction Call to deprecated function \NDB_BVL_Instrument::loadInstanceData() defined at php/libraries/NDB_BVL_Instrument.class.inc:2170 (Deprecated because: use $instrumentInstance->getInstanceData() instead)
test/unittests/NDB_BVL_Instrument_Test.php:1566 PhanDeprecatedFunction Call to deprecated function \NDB_BVL_Instrument::loadInstanceData() defined at php/libraries/NDB_BVL_Instrument.class.inc:2170 (Deprecated because: use $instrumentInstance->getInstanceData() instead)
test/unittests/NDB_BVL_Instrument_Test.php:1601 PhanDeprecatedFunction Call to deprecated function \NDB_BVL_Instrument::loadInstanceData() defined at php/libraries/NDB_BVL_Instrument.class.inc:2170 (Deprecated because: use $instrumentInstance->getInstanceData() instead)
test/unittests/NDB_BVL_Instrument_Test.php:1678 PhanDeprecatedFunction Call to deprecated function \NDB_BVL_Instrument::loadInstanceData() defined at php/libraries/NDB_BVL_Instrument.class.inc:2170 (Deprecated because: use $instrumentInstance->getInstanceData() instead)

@laemtl laemtl self-requested a review November 20, 2020 19:58
Copy link
Contributor

@laemtl laemtl left a comment

Choose a reason for hiding this comment

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

Phan errors need to be fixed (see above). NDB_BVL_Instrument_Test.php was added after the PR so a rebase is needed.

* @return void
*/
function testLoadInstanceData()
function getLoadInstanceData()
Copy link
Contributor

Choose a reason for hiding this comment

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

testGetInstanceData?

@laemtl
Copy link
Contributor

laemtl commented Nov 20, 2020

One test is failing.

  1. Loris\Tests\NDB_BVL_Instrument_Test::testNullScores
    Failed asserting that 'Test Examiner1' matches expected null.

/app/test/unittests/NDB_BVL_Instrument_Test.php:1602

@laemtl laemtl self-requested a review November 20, 2020 20:33
@laemtl
Copy link
Contributor

laemtl commented Nov 20, 2020

Impressive, the tests are running really fast with Github actions.

@driusan
Copy link
Collaborator Author

driusan commented Nov 20, 2020

I think the individual test suites take about the same amount of time, but they start a lot faster.

@driusan driusan merged commit 4621058 into aces:main Nov 20, 2020
@ridz1208 ridz1208 added this to the 24.0.0 milestone Nov 27, 2020
AlexandraLivadas pushed a commit to AlexandraLivadas/Loris that referenced this pull request Jun 29, 2021
NDB_BVL_Instrument has an.. unusual.. way of dealing with instrument
data. Rather than having a class method for getting the data, there's
a static method which takes an instrument as a parameter. The result
is that data can not be cached in the object and needs to be continuously
re-loaded from the database every time if it's needed multiple times in
the same request. (For instance, calling getFieldValue for different fields
in a script.)

This adds a normal getter and caches the results in the object, deprecating
the old static loadInstanceData.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocking PR should be prioritized because it is blocking the progress of another task Meta PR does something that organizes, upgrades, or manages the functionality of the codebase Passed manual tests PR has been successfully tested by at least one peer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants