Skip to content

Fix #5128 - Properly remove old components/measures when updating#5129

Merged
jmarrec merged 1 commit intodevelopfrom
5128_remove_old_versions
Mar 27, 2024
Merged

Fix #5128 - Properly remove old components/measures when updating#5129
jmarrec merged 1 commit intodevelopfrom
5128_remove_old_versions

Conversation

@jmarrec
Copy link
Copy Markdown
Collaborator

@jmarrec jmarrec commented Mar 27, 2024

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added component - Measures Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Mar 27, 2024
@jmarrec jmarrec self-assigned this Mar 27, 2024
@jmarrec jmarrec force-pushed the 5128_remove_old_versions branch from 9fa472d to 0285e41 Compare March 27, 2024 11:29
Comment on lines +100 to +104
// Removes all components with uid but NOT currentVersionId
size_t removeOutdatedLocalComponents(const std::string& uid, const std::string& currentVersionId);

// Removes all measures with uid but NOT currentVersionId
size_t removeOutdatedLocalMeasures(const std::string& uid, const std::string& currentVersionId);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

New LocalBCL methods. Returns the number removed

if (oldComponent && oldComponent->versionId() != newComponent->versionId()) {
LocalBCL::instance().removeComponent(*oldComponent);
}
LocalBCL::instance().removeOutdatedLocalComponents(newComponent->uid(), newComponent->versionId());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

in updateComponents, remove the outdated local ones if suceeded

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The important bit is explained at #5128 (comment)

getComponent does a sqlite3 SELECT, which does NOT guarantee the order of return is in the same order it was inserted. so we can't use it

if (oldMeasure && oldMeasure->versionId() != newMeasure->versionId()) {
LocalBCL::instance().removeMeasure(*oldMeasure);
}
LocalBCL::instance().removeOutdatedLocalMeasures(newMeasure->uid(), newMeasure->versionId());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same on updateMeasures

@jmarrec jmarrec merged commit ab2d186 into develop Mar 27, 2024
@jmarrec jmarrec deleted the 5128_remove_old_versions branch March 27, 2024 16:19
@macumber
Copy link
Copy Markdown
Contributor

@jmarrec thanks, I like this better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component - Measures Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RemoteBCL updateMeasures does not reliably remove old version

3 participants