-
-
Notifications
You must be signed in to change notification settings - Fork 506
Reduce noisy change events #2438
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
5b319fb
f8449f0
15e27df
e3e1f6d
8895405
2e96f54
d9508d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,30 @@ | |
|
|
||
| angular | ||
| .module("exceptionless.organization", ["restangular"]) | ||
| .factory("organizationService", function ($cacheFactory, $rootScope, objectIDService, Restangular) { | ||
| .factory("organizationService", function ($cacheFactory, $interval, $rootScope, objectIDService, Restangular) { | ||
| var _cache = $cacheFactory("http:organization"); | ||
| var _usageMonth = getUsageMonth(); | ||
| $rootScope.$on("cache:clear", _cache.removeAll); | ||
| $rootScope.$on("cache:clear-organization", _cache.removeAll); | ||
| $rootScope.$on("auth:logout", _cache.removeAll); | ||
| $rootScope.$on("OrganizationChanged", _cache.removeAll); | ||
| $rootScope.$on("ProjectChanged", _cache.removeAll); | ||
| $rootScope.$on("PlanOverage", _cache.removeAll); | ||
|
|
||
| $interval(function () { | ||
| var usageMonth = getUsageMonth(); | ||
| if (usageMonth === _usageMonth) { | ||
| return; | ||
| } | ||
|
|
||
| _usageMonth = usageMonth; | ||
| $rootScope.$broadcast("OrganizationChanged"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At UTC month rollover, this broadcasts Useful? React with 👍 / 👎. |
||
| }, 60000); | ||
|
|
||
| function getUsageMonth() { | ||
| var now = new Date(); | ||
| return now.getUTCFullYear() * 12 + now.getUTCMonth(); | ||
| } | ||
|
|
||
| $rootScope.$on("StackChanged", function ($event, data) { | ||
| if (data.added) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { QueryClient } from '@tanstack/svelte-query'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { invalidateOrganizationUsageQueries, invalidatePlanOverageQueries, queryKeys } from './api.svelte'; | ||
|
|
||
| describe('invalidatePlanOverageQueries', () => { | ||
| it('invalidates only the affected organization state', async () => { | ||
| // Arrange | ||
| const queryClient = new QueryClient(); | ||
| const invalidateSpy = vi.spyOn(queryClient, 'invalidateQueries').mockImplementation(async () => {}); | ||
|
|
||
| // Act | ||
| await invalidatePlanOverageQueries(queryClient, { | ||
| is_hourly: false, | ||
| organization_id: 'organization-id' | ||
| }); | ||
|
|
||
| // Assert | ||
| expect(invalidateSpy).toHaveBeenCalledTimes(3); | ||
| expect(invalidateSpy).toHaveBeenCalledWith({ exact: true, queryKey: queryKeys.id('organization-id', undefined) }); | ||
| expect(invalidateSpy).toHaveBeenCalledWith({ exact: true, queryKey: queryKeys.id('organization-id', 'stats') }); | ||
| expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: queryKeys.list(undefined) }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('invalidateOrganizationUsageQueries', () => { | ||
| it('invalidates organization lists when there is no active organization', async () => { | ||
| // Arrange | ||
| const queryClient = new QueryClient(); | ||
| const invalidateSpy = vi.spyOn(queryClient, 'invalidateQueries').mockImplementation(async () => {}); | ||
|
|
||
| // Act | ||
| await invalidateOrganizationUsageQueries(queryClient); | ||
|
|
||
| // Assert | ||
| expect(invalidateSpy).toHaveBeenCalledOnce(); | ||
| expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: queryKeys.list(undefined) }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an organization's temporary event bonus expires without another usage bucket being saved,
realTimeUsage.CurrentUsage.Limitstill contains the bonus-inflated limit written byBillingManager.ApplyBonus, whileGetMaxEventsPerMonthWithBonusalready returns the lower effective limit. This assignment therefore overrides the mapper's previously correctIsOverMonthlyLimitvalue and can leave the API response and overage banner false even when the persisted-plus-pending total now exceeds the live limit; compare the total againstviewOrganization.GetMaxEventsPerMonthWithBonus(timeProvider)instead.AGENTS.md reference: AGENTS.md:L67-L67
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 2aa10d3: real-time usage totals are now compared against the organization view model live effective monthly limit, so an expired bonus cannot keep the overage state false. The focused regression failed before the fix with Expected True, Actual False; OrganizationEndpointTests now pass 103 of 103 and the build is clean.