Skip to content

Commit 7a6ba01

Browse files
committed
Fixed bug where GetHourlyEventLimit would return a higher limit than remaining events
If you had less than 10 hours left in the month, the number created was higher than then event left
1 parent 84d949b commit 7a6ba01

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Exceptionless.Core/Extensions/OrganizationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static int GetHourlyEventLimit(this Organization organization) {
5858

5959
var utcNow = SystemClock.UtcNow;
6060
var hoursLeftInMonth = (utcNow.EndOfMonth() - utcNow).TotalHours;
61-
if (hoursLeftInMonth < 1.0)
61+
if (hoursLeftInMonth < 10.0)
6262
return eventsLeftInMonth;
6363

6464
return (int)Math.Ceiling(eventsLeftInMonth / hoursLeftInMonth * 10d);

tests/Exceptionless.Api.Tests/Repositories/OrganizationRepositoryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public OrganizationRepositoryTests(ITestOutputHelper output) : base(output) {
3030

3131
Log.SetLogLevel<OrganizationRepository>(LogLevel.Trace);
3232
}
33-
33+
3434
[Fact]
3535
public async Task CanCreateUpdateRemoveAsync() {
3636
Assert.Equal(0, await _repository.CountAsync());
@@ -137,7 +137,7 @@ public async Task CanIncrementUsageAsync() {
137137
Assert.True(await _repository.IncrementUsageAsync(o.Id, false, 2));
138138
await _configuration.Client.RefreshAsync(Indices.All);
139139
o = await _repository.GetByIdAsync(o.Id);
140-
140+
141141
await countdown.WaitAsync(TimeSpan.FromMilliseconds(150));
142142
Assert.Equal(1, countdown.CurrentCount);
143143
Assert.Equal(totalToIncrement + 2, await _cache.GetAsync<long>(GetHourlyTotalCacheKey(o.Id), 0));
@@ -184,7 +184,7 @@ public async Task CanIncrementSuspendedOrganizationUsageAsync() {
184184
o.SuspensionDate = SystemClock.UtcNow;
185185
o.SuspensionCode = SuspensionCode.Billing;
186186
o = await _repository.SaveAsync(o, true);
187-
187+
188188
Assert.True(await _repository.IncrementUsageAsync(o.Id, false, 4995));
189189

190190
await countdown.WaitAsync(TimeSpan.FromMilliseconds(150));

0 commit comments

Comments
 (0)