fix: respect test_index when creating optimization_features row
The get_or_create defaults passed test lists without positional indexing, so when a higher test_index created the row first its content landed at index 0 and was overwritten by the lower index update, losing a test.
This commit is contained in:
parent
6346d0992a
commit
bfd9f2cd04
1 changed files with 12 additions and 3 deletions
|
|
@ -17,6 +17,15 @@ if TYPE_CHECKING:
|
|||
features_api = NinjaAPI(urls_namespace="log_features")
|
||||
|
||||
|
||||
def _positional_list(items: list[str] | None, index: int | None) -> list[str | None] | None:
|
||||
"""Place a single item at the correct index, padding with None."""
|
||||
if not items or index is None or len(items) != 1:
|
||||
return items
|
||||
result: list[str | None] = [None] * (index + 1)
|
||||
result[index] = items[0]
|
||||
return result
|
||||
|
||||
|
||||
@sync_to_async
|
||||
@transaction.atomic
|
||||
def log_features(
|
||||
|
|
@ -89,9 +98,9 @@ def log_features(
|
|||
"optimized_runtime": optimized_runtime,
|
||||
"optimized_line_profiler_results": optimized_line_profiler_results,
|
||||
"is_correct": is_correct,
|
||||
"generated_test": generated_tests,
|
||||
"instrumented_generated_test": instrumented_generated_tests,
|
||||
"instrumented_perf_test": instrumented_perf_tests,
|
||||
"generated_test": _positional_list(generated_tests, test_index),
|
||||
"instrumented_generated_test": _positional_list(instrumented_generated_tests, test_index),
|
||||
"instrumented_perf_test": _positional_list(instrumented_perf_tests, test_index),
|
||||
"test_framework": test_framework,
|
||||
"created_at": datetime,
|
||||
"aiservice_commit_id": aiservice_commit,
|
||||
|
|
|
|||
Loading…
Reference in a new issue