This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Toast notifications for Azure pull requests (Rejected and Approved) #245
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ba7f9e9
Add PR status
dkbennett 8adb91b
Use workitem and identity index lookups instead of embedding
dkbennett 3dda206
Add notifications and pull request status tracking
dkbennett ae3b308
Add policy status and notification test
dkbennett fcc61e2
Add add stale checks to pull request data, update based on push
dkbennett e39e4ed
Use UtcNow
dkbennett 7bc506f
Make developerLoginId nullable
dkbennett 67146a6
Remove dead code, fix comment
dkbennett d2b018b
Swap operation names to a constant
dkbennett 1e82f94
Review feedback
dkbennett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using DevHomeAzureExtension.DataManager; | ||
| using DevHomeAzureExtension.DataModel; | ||
| using Microsoft.TeamFoundation.Policy.WebApi; | ||
| using Serilog; | ||
|
|
||
| namespace DevHomeAzureExtension; | ||
|
|
||
| public partial class AzureDataManager | ||
| { | ||
| // This is how frequently the DataStore update occurs. | ||
| private static readonly TimeSpan _updateInterval = TimeSpan.FromMinutes(5); | ||
| private static DateTime _lastUpdateTime = DateTime.MinValue; | ||
|
|
||
| public static async Task Update() | ||
| { | ||
| // Only update per the update interval. | ||
| // This is intended to be dynamic in the future. | ||
| if (DateTime.UtcNow - _lastUpdateTime < _updateInterval) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| await UpdateDeveloperPullRequests(); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Log.Error(ex, "Update failed unexpectedly."); | ||
| } | ||
|
|
||
| _lastUpdateTime = DateTime.UtcNow; | ||
| } | ||
|
|
||
| public static async Task UpdateDeveloperPullRequests() | ||
| { | ||
| var log = Log.ForContext("SourceContext", $"UpdateDeveloperPullRequests"); | ||
| log.Debug($"Executing UpdateDeveloperPullRequests"); | ||
|
|
||
| var cacheManager = CacheManager.GetInstance(); | ||
| if (cacheManager.UpdateInProgress) | ||
| { | ||
| log.Information("Cache is being updated, skipping Developer Pull Request Update"); | ||
| return; | ||
| } | ||
|
|
||
| var identifier = Guid.NewGuid(); | ||
| using var dataManager = CreateInstance(identifier.ToString()) ?? throw new DataStoreInaccessibleException(); | ||
| await dataManager.UpdatePullRequestsForLoggedInDeveloperIdsAsync(null, identifier); | ||
|
|
||
| // Show any new notifications that were created from the pull request update. | ||
| var notifications = dataManager.GetNotifications(); | ||
| foreach (var notification in notifications) | ||
| { | ||
| // Show notifications for failed checkruns for Developer users. | ||
| if (notification.Type == NotificationType.PullRequestRejected || notification.Type == NotificationType.PullRequestApproved) | ||
| { | ||
| notification.ShowToast(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.