[OPIK-3073] [BE] Make to time optional#4087
Merged
thiagohora merged 4 commits intomainfrom Nov 17, 2025
Merged
Conversation
…and optimize fill_to template
Contributor
SDK E2E Tests Results0 tests 0 ✅ 0s ⏱️ Results for commit 60c4612. |
Contributor
SDK E2E Tests Results0 tests 0 ✅ 0s ⏱️ Results for commit 60c4612. ♻️ This comment has been updated with latest results. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the ProjectMetricsDAO implementation by refactoring statement creation patterns and SQL template handling. The changes address code review feedback to improve efficiency and consistency across metric queries.
Key changes:
- Optimized statement creation in
getTotalCost()andgetAverageDuration()to set template flags before rendering, eliminating duplicate statement creation - Made
WITH FILLclauses conditional inGET_COSTandGET_GUARDRAILS_FAILED_COUNTqueries for consistency with other metric queries - Removed redundant
fill_totemplate variable by hardcoding the TO clause directly in SQL templates
Contributor
Backend Tests Results 290 files 290 suites 50m 7s ⏱️ Results for commit 60c4612. |
andrescrz
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revision 3: Address GitHub PR Comments - Refactor Statement Creation and Optimize Template Variables
Details
Refactored
ProjectMetricsDAOto address code review feedback from GitHub Copilot and @andrescrz, improving efficiency and code quality while maintaining all existing functionality.Changes Made
1. Fixed Statement Creation Inefficiency (Comments #1 & #2)
Methods affected:
getTotalCost()andgetAverageDuration()Problem:
render()callendTime != null, discarding the first instanceSolution:
// Before (inefficient):
// After (optimized):
2. Removed Unnecessary
fill_toTemplate Variable (Comment #3)Methods affected:
getMetric()Problem:
fill_totemplate variable was always set to the same valueSolution:
// Before:
// SQL template:
// After:
// Removed template.add("fill_to", ...) line
// SQL template (hardcoded TO clause):
Benefits:
3. Made GET_COST and GET_GUARDRAILS_FAILED_COUNT Conditional
Queries affected:
GET_COSTandGET_GUARDRAILS_FAILED_COUNTProblem:
WITH FILLclausesuuid_to_timeis null (optionalto_timeparameter)Solution:
// Before:
// After:
Benefits:
interval_endparameterBehavioral Impact
When
to_time/interval_endis provided:with_fillflag set totrueWITH FILLclause included in SQL:uuid_to_timeparameter bound and usedWhen
to_time/interval_endis omitted (common case):with_fillflag remainsfalseWITH FILLclause excluded from SQL (via<if(with_fill)>):uuid_to_timeparameter not bound (not needed)Change checklist
Issues
OPIK-3073
Testing
interval_endprovided and omittedDocumentation
NA