Skip to content

Commit

Permalink
Merge branch 'release/3.814.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Dec 12, 2024
2 parents 5811e81 + b73950d commit ca99b12
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<!-- These properties will be shared for all projects -->
<PropertyGroup>
<VersionPrefix>3.813.0</VersionPrefix>
<VersionPrefix>3.814.0</VersionPrefix>
<VersionSuffix>
</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public class SequenceNumberGeneratorOptions
/// Defines the delay between retries in seconds.
/// </summary>
public int RetryDelay { get; set; } = 5;

/// <summary>
/// Defines usage of the static tenant id instead of store id for generating unique number.
/// Can be useful when you want to have golobal counter for all stores/tenants.
/// </summary>
public bool UseGlobalTenantId { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected virtual RetryPolicy ConfigureRetryPolicy()
/// <returns></returns>
protected virtual int RequestNextCounter(string tenantId, CounterOptions counterOptions)
{
var sequenceKey = string.IsNullOrEmpty(tenantId) ? counterOptions.NumberTemplate : $"{tenantId}/{counterOptions.NumberTemplate}";
var sequenceKey = GetSequenceKey(tenantId, counterOptions);

using var repository = _repositoryFactory();
var sequence = repository.Sequences.SingleOrDefault(s => s.ObjectType == sequenceKey);
Expand Down Expand Up @@ -177,6 +177,16 @@ protected virtual int RequestNextCounter(string tenantId, CounterOptions counter
return sequence.Value;
}

protected virtual string GetSequenceKey(string tenantId, CounterOptions counterOptions)
{
if(_options.UseGlobalTenantId || string.IsNullOrEmpty(tenantId))
{
return counterOptions.NumberTemplate;
}

return $"{tenantId}/{counterOptions.NumberTemplate}";
}

/// <summary>
/// Returns true if counter should be reset.
/// </summary>
Expand All @@ -193,7 +203,7 @@ protected virtual bool ShouldResetCounter(DateTime lastResetDate, ResetCounterTy
return currentUtcDate.Date > lastResetDate.Date;
case ResetCounterType.Weekly:
// Reset every Monday
int daysUntilTargetDay = ((int)DayOfWeek.Monday - (int)lastResetDate.DayOfWeek + 7) % 7;
var daysUntilTargetDay = ((int)DayOfWeek.Monday - (int)lastResetDate.DayOfWeek + 7) % 7;
var nextMondayDate = lastResetDate.Date.AddDays(daysUntilTargetDay);
return currentUtcDate >= nextMondayDate;
case ResetCounterType.Monthly:
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.CoreModule.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<id>VirtoCommerce.Core</id>
<version>3.813.0</version>
<version>3.814.0</version>
<version-tag />
<platformVersion>3.853.0</platformVersion>
<title>Commerce core module</title>
Expand Down

0 comments on commit ca99b12

Please sign in to comment.