Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Reporting Service #2218

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Fix Reporting Service #2218

merged 1 commit into from
Aug 27, 2024

Conversation

Fosol
Copy link
Collaborator

@Fosol Fosol commented Aug 27, 2024

The Reporting Service can now be configured to resend on failures, and whether it will attempt to send the report to every subscriber before it logs the report send as a failure. This provides a way to get a report out to subscribers when only a single subscriber's email is failing.

Summary

  • Updated Reporting Service
  • Updated API

Reporting Service Configuration Options

  • ResendOnFailure = Whether a failure will result in another attempt
  • ResendAttemptLimit = Only retry a failed report this many times
  • SendToAllSubscribersBeforeFailing = Whether to attempt to send to all subscribers and ignore failures
  • RetryConcurrencyFailureLimit = Limit on concurrency error retries

@Fosol Fosol added the bug Something isn't working label Aug 27, 2024
@Fosol Fosol self-assigned this Aug 27, 2024
@@ -217,7 +217,7 @@ public async Task<IActionResult> SendToAsync(int id, string to)
var username = User.GetUsername() ?? throw new NotAuthorizedException("Username is missing");
var user = _userService.FindByUsername(username) ?? throw new NotAuthorizedException($"User [{username}] does not exist");

var request = new ReportRequestModel(ReportDestination.ReportingService, Entities.ReportType.Content, report.Id, new { })
var request = new ReportRequestModel(ReportDestination.ReportingService, Entities.ReportType.Content, report.Id, JsonDocument.Parse("{}"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed to change to JsonDocument because it was being used inconsistently with a dynamic object.

JsonValueKind.String => !typeof(T).IsEnum ?
(T)Convert.ChangeType($"{node.GetString()}".Trim(), typeof(T)) :
(T)Enum.Parse(typeof(T), node.GetString() ?? ""),
JsonValueKind.String => ((Func<T?>)(() =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed parsing issue with nullable enum values

/// Get the preferred email if it has been set.
/// </summary>
/// <returns></returns>
public string[] GetEmails()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not needed

@@ -182,7 +182,7 @@ public override async Task RunAsync()
// Reached limit return to ingest manager, send email.
if (manager.Ingest.FailedAttempts >= manager.Ingest.RetryLimit)
{
await this.SendEmailAsync($"Ingest [{ingest.Name}] failed. Reached [{manager.Ingest.RetryLimit}] maximum retries.", ex);
await this.SendErrorEmailAsync($"Ingest [{ingest.Name}] failed. Reached [{manager.Ingest.RetryLimit}] maximum retries.", ex);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed method to make it clear

@@ -7,5 +7,5 @@ public enum ReportingErrors
FailedToAddInstance = 2,
FailedToUpdateInstance = 3,
FailedToGenerateOutput = 4,
FailedToEmail = 4,
FailedToEmail = 5,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed enum bug

@Fosol Fosol merged commit 03b833c into bcgov:dev Aug 27, 2024
1 check passed
@Fosol Fosol deleted the report branch August 27, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant