Skip to content

Commit

Permalink
feat: Allow disabling of only WeeklyTaskOwnerReportSender (#728)
Browse files Browse the repository at this point in the history
- [x] New feature
- [ ] Bug fix
- [ ] High impact

**Description of work:**
<!--- Please give a description of the work --->

Allow for disabling sending of notification for **only** weekly task
owner sender. This will allow us to test it without sending the report

**Testing:**
- [x] Can be tested
- [ ] Automatic tests created / updated
- [ ] Local tests are passing

<!--- Please give a description of how this can be tested --->

Ran pipeline with this PR. Did a dry run in prod

**Checklist:**
- [ ] Considered automated tests
- [ ] Considered updating specification / documentation
- [ ] Considered work items 
- [ ] Considered security
- [x] Performed developer testing
- [x] Checklist finalized / ready for review

<!--- Other comments --->
  • Loading branch information
Jonathanio123 authored Dec 11, 2024
1 parent 6cd9ae9 commit ad5f41c
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class WeeklyTaskOwnerReportSender
private readonly bool sendingNotificationEnabled = true; // Default to true so that we don't accidentally disable sending notifications
private readonly string fusionUri;

private const string IsSendingNotificationEnabledKey = "WeeklyTaskOwnerReport_IsSendingNotificationEnabled";
private const string FunctionName = "weekly-task-owner-report-sender";

public WeeklyTaskOwnerReportSender(ILogger<WeeklyTaskOwnerReportSender> logger, IConfiguration configuration, ISummaryApiClient summaryApiClient, IMailApiClient mailApiClient, IPeopleApiClient peopleApiClient, IContextApiClient contextApiClient)
{
this.logger = logger;
Expand All @@ -39,14 +42,12 @@ public WeeklyTaskOwnerReportSender(ILogger<WeeklyTaskOwnerReportSender> logger,
fusionUri = (configuration["Endpoints_portal"] ?? "https://fusion.equinor.com/").TrimEnd('/');

// Need to explicitly add the configuration key to the app settings to disable sending of notifications
if (int.TryParse(configuration["isSendingNotificationEnabled"], out var enabled))
if (int.TryParse(configuration[IsSendingNotificationEnabledKey], out var enabled))
sendingNotificationEnabled = enabled == 1;
else if (bool.TryParse(configuration["isSendingNotificationEnabled"], out var enabledBool))
else if (bool.TryParse(configuration[IsSendingNotificationEnabledKey], out var enabledBool))
sendingNotificationEnabled = enabledBool;
}

private const string FunctionName = "weekly-task-owner-report-sender";

[FunctionName(FunctionName)]
public async Task RunAsync([TimerTrigger("0 0 5 * * MON", RunOnStartup = false)] TimerInfo timerInfo, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -287,8 +288,8 @@ private SendEmailWithTemplateRequest CreateReportMail(string[] recipients, Proje
}
}, new GoToAction()
{
Title = "Go to position overview",
Url = $"{fusionUri}/apps/org-admin/{contextId}/edit-positions/listing-view"
Title = "Go to positions listing view",
Url = $"{fusionUri}/apps/org-admin/{contextId}/edit-positions/listing-view?filter=allocations-exp-3m"
})
.AddGrid("TBN positions with start date next 3 months", "(Please create a resource request or update the position start-date)", new List<GridColumn>()
{
Expand All @@ -314,7 +315,7 @@ private SendEmailWithTemplateRequest CreateReportMail(string[] recipients, Proje
}
}, new GoToAction()
{
Title = "Go to position overview",
Title = "Go to positions listing view",
Url = $"{fusionUri}/apps/org-admin/{contextId}/edit-positions/listing-view?filter=tbn-pos-3m"
})
.Build();
Expand Down

0 comments on commit ad5f41c

Please sign in to comment.