Update and optimize WorkflowDefinitionStore logic (#5462)
The update involves optimizing the WorkflowDefinitionStore logic. The minor change is that it removed an unneeded space in the CountDistinctAsync method. More importantly, an upgrade issue with 'IsSystem' from older versions of Elsa to 3.2 has been rectified by adding checks and conditions to suit legacy versions. In the future, once all systems are updated, this check can be removed.
This commit is contained in:
parent
411151d748
commit
51cd3fa851
|
|
@ -140,7 +140,7 @@ public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
|
|||
/// <inheritdoc />
|
||||
public async Task<long> CountDistinctAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _store.CountAsync(x => true, x => x.DefinitionId, cancellationToken);
|
||||
return await _store.CountAsync(x => true, x => x.DefinitionId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -193,7 +193,14 @@ public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
|
|||
if (filter.Names != null) queryable = queryable.Where(x => filter.Names.Contains(x.Name!));
|
||||
if (filter.UsableAsActivity != null) queryable = queryable.Where(x => EF.Property<bool>(x, "UsableAsActivity") == filter.UsableAsActivity);
|
||||
if (!string.IsNullOrWhiteSpace(filter.SearchTerm)) queryable = queryable.Where(x => x.Name!.Contains(filter.SearchTerm) || x.Description!.Contains(filter.SearchTerm) || x.Id.Contains(filter.SearchTerm) || x.DefinitionId.Contains(filter.SearchTerm));
|
||||
if (filter.IsSystem != null) queryable = queryable.Where(x => x.IsSystem == filter.IsSystem);
|
||||
|
||||
// TEMP: IsSystem may be null when upgrading from older versions of Elsa to 3.2. See issue #5366.
|
||||
// In a future version, we should remove this check and simply do queryable.Where(x => x.IsSystem == filter.IsSystem).
|
||||
if (filter.IsSystem != null)
|
||||
queryable = filter.IsSystem == true
|
||||
? queryable.Where(x => x.IsSystem == true)
|
||||
: queryable.Where(x => x.IsSystem == false || x.IsSystem == null);
|
||||
|
||||
if (filter.IsReadonly != null) queryable = queryable.Where(x => x.IsReadonly == filter.IsReadonly);
|
||||
return queryable;
|
||||
}
|
||||
|
|
@ -204,7 +211,7 @@ public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
|
|||
if (pageArgs?.Limit != null) queryable = queryable.Take(pageArgs.Limit.Value);
|
||||
return queryable;
|
||||
}
|
||||
|
||||
|
||||
private class WorkflowDefinitionState
|
||||
{
|
||||
[JsonConstructor]
|
||||
|
|
|
|||
Loading…
Reference in a new issue