Skip to content

Conversation

harshithb3304
Copy link
Contributor

…n logic

@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 15:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds dynamic API error calculation functionality to track specific error types (Cloudflare errors, 429 rate limits, and 5xx server errors) in testing results. The implementation adds error categorization and counting capabilities to the testing framework.

  • Introduces a new apiErrors field to store error counts by type
  • Implements regex-based error detection for Cloudflare, 429, and 5xx errors
  • Adds database indexing support for the new error tracking field

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
TestingRunResult.java Adds apiErrors field with getter/setter methods
TestingRunResultDao.java Creates database index for the new apiErrors field
DbAction.java Implements error detection logic using regex patterns and populates apiErrors map

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

testingRunResult.setTestRunResultSummaryId(id);
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

we need the API to be fast.
make a scheduleExecutor with fixed threads [ say 10 ].
let the actual update happen [ without apiErrors ].
submit a job to executor which runs the regex.
if apiErrors are > 0 , issue an update, else skip updates altogether.
this will help in better find query performance, because we would be able to use the $exists paradigm.

Comment on lines 1980 to 1985
final TestingRunResult trrForAsync = testingRunResult;
final int capturedAccountId = (Context.accountId.get() != null) ? Context.accountId.get() : 0;
apiErrorsService.submit(() -> {
if (capturedAccountId != 0) {
Context.accountId.set(capturedAccountId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

don't run the thread altogether, if accountId is 0

if (cloudflareErrors + rateLimit429 + server5xx > 0) {
try {
// set apiErrors field on the existing document
org.bson.conversions.Bson filter = Filters.eq("_id", trrForAsync.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

always use string literals, for all string fields.
i.e. instead of _id, use Constants._ID and define it somewhere [ I think it's already defined somewhere ].

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants