Skip to content

Commit

Permalink
[QC-429] NewObject uses validFrom for old, validUntil-1 for new valid…
Browse files Browse the repository at this point in the history
…ity (#1862)
  • Loading branch information
knopers8 authored Jun 30, 2023
1 parent 5e7e5d3 commit 7ddff64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Framework/include/QualityControl/ActivityHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ core::Activity asActivity(const boost::property_tree::ptree&, const std::string&
std::function<validity_time_t(void)> getCcdbSorTimeAccessor(uint64_t runNumber);
std::function<validity_time_t(void)> getCcdbEorTimeAccessor(uint64_t runNumber);

/// \brief checks if the provided validity uses old rules, where start is creation time, end is 10 years in the future.
bool isLegacyValidity(ValidityInterval);

namespace implementation
{
template <typename Iter, typename Accessor>
Expand Down
5 changes: 5 additions & 0 deletions Framework/src/ActivityHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ std::function<validity_time_t(void)> getCcdbEorTimeAccessor(uint64_t runNumber)
return [runNumber]() { return static_cast<validity_time_t>(ccdb::BasicCCDBManager::instance().getRunDuration(runNumber, false).second); };
}

bool isLegacyValidity(ValidityInterval validity)
{
return validity.isValid() && validity.delta() > 9ull * 365 * 24 * 60 * 60 * 1000ull;
}

} // namespace o2::quality_control::core::activity_helpers
3 changes: 2 additions & 1 deletion Framework/src/Triggers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ TriggerFcn NewObject(const std::string& databaseUrl, const std::string& database
return [objectActivity, config, newObjectValidity]() mutable -> Trigger {
if (auto validity = newObjectValidity(); validity.isValid()) {
objectActivity.mValidity = validity;
return { TriggerType::NewObject, false, objectActivity, validity.getMax(), config };
auto timestamp = activity_helpers::isLegacyValidity(validity) ? validity.getMin() : (validity.getMax() - 1);
return { TriggerType::NewObject, false, objectActivity, timestamp, config };
}
objectActivity.mValidity = gInvalidValidityInterval;
return { TriggerType::No, false, objectActivity, Trigger::msSinceEpoch(), config };
Expand Down

0 comments on commit 7ddff64

Please sign in to comment.