Use DateTime instead of DateTimeOffset due to YesSql bug
See: https://github.com/sebastienros/yessql/issues/325
This commit is contained in:
parent
9b76904099
commit
f456d4ec3e
|
|
@ -18,11 +18,11 @@ namespace Elsa.Persistence.YesSql.Indexes
|
|||
public string? ContextId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public WorkflowStatus WorkflowStatus { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset? LastExecutedAt { get; set; }
|
||||
public DateTimeOffset? FinishedAt { get; set; }
|
||||
public DateTimeOffset? CancelledAt { get; set; }
|
||||
public DateTimeOffset? FaultedAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime? LastExecutedAt { get; set; }
|
||||
public DateTime? FinishedAt { get; set; }
|
||||
public DateTime? CancelledAt { get; set; }
|
||||
public DateTime? FaultedAt { get; set; }
|
||||
}
|
||||
|
||||
public class WorkflowInstanceBlockingActivitiesIndex : MapIndex
|
||||
|
|
@ -32,7 +32,7 @@ namespace Elsa.Persistence.YesSql.Indexes
|
|||
public string ActivityType { get; set; } = default!;
|
||||
public string? CorrelationId { get; set; }
|
||||
public WorkflowStatus WorkflowStatus { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class WorkflowInstanceIndexProvider : IndexProvider<WorkflowInstanceDocument>
|
||||
|
|
@ -54,11 +54,11 @@ namespace Elsa.Persistence.YesSql.Indexes
|
|||
ContextType = workflowInstance.ContextType,
|
||||
ContextId = workflowInstance.ContextId,
|
||||
Name = workflowInstance.Name,
|
||||
CreatedAt = workflowInstance.CreatedAt.ToDateTimeOffset(),
|
||||
CancelledAt = workflowInstance.CancelledAt?.ToDateTimeOffset(),
|
||||
FinishedAt = workflowInstance.FinishedAt?.ToDateTimeOffset(),
|
||||
LastExecutedAt = workflowInstance.LastExecutedAt?.ToDateTimeOffset(),
|
||||
FaultedAt = workflowInstance.FaultedAt?.ToDateTimeOffset()
|
||||
CreatedAt = workflowInstance.CreatedAt.ToDateTimeUtc(),
|
||||
CancelledAt = workflowInstance.CancelledAt?.ToDateTimeUtc(),
|
||||
FinishedAt = workflowInstance.FinishedAt?.ToDateTimeUtc(),
|
||||
LastExecutedAt = workflowInstance.LastExecutedAt?.ToDateTimeUtc(),
|
||||
FaultedAt = workflowInstance.FaultedAt?.ToDateTimeUtc()
|
||||
});
|
||||
|
||||
context.For<WorkflowInstanceBlockingActivitiesIndex>()
|
||||
|
|
@ -77,7 +77,7 @@ namespace Elsa.Persistence.YesSql.Indexes
|
|||
CorrelationId = workflowInstance.CorrelationId,
|
||||
TenantId = workflowInstance.TenantId,
|
||||
WorkflowStatus = workflowInstance.WorkflowStatus,
|
||||
CreatedAt = workflowInstance.CreatedAt.ToDateTimeOffset()
|
||||
CreatedAt = workflowInstance.CreatedAt.ToDateTimeUtc()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ namespace Elsa.Persistence.YesSql
|
|||
.Column<string?>(nameof(WorkflowInstanceIndex.ContextType))
|
||||
.Column<string?>(nameof(WorkflowInstanceIndex.Name))
|
||||
.Column(nameof(WorkflowInstanceIndex.WorkflowStatus), DbType.String)
|
||||
.Column(nameof(WorkflowInstanceIndex.CreatedAt), DbType.DateTimeOffset)
|
||||
.Column(nameof(WorkflowInstanceIndex.LastExecutedAt), DbType.DateTimeOffset)
|
||||
.Column(nameof(WorkflowInstanceIndex.FinishedAt), DbType.DateTimeOffset)
|
||||
.Column(nameof(WorkflowInstanceIndex.CancelledAt), DbType.DateTimeOffset)
|
||||
.Column(nameof(WorkflowInstanceIndex.FaultedAt), DbType.DateTimeOffset)
|
||||
.Column(nameof(WorkflowInstanceIndex.CreatedAt), DbType.DateTime)
|
||||
.Column(nameof(WorkflowInstanceIndex.LastExecutedAt), DbType.DateTime)
|
||||
.Column(nameof(WorkflowInstanceIndex.FinishedAt), DbType.DateTime)
|
||||
.Column(nameof(WorkflowInstanceIndex.CancelledAt), DbType.DateTime)
|
||||
.Column(nameof(WorkflowInstanceIndex.FaultedAt), DbType.DateTime)
|
||||
,
|
||||
CollectionNames.WorkflowInstances);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace Elsa.Persistence.YesSql
|
|||
.Column<string>(nameof(WorkflowInstanceBlockingActivitiesIndex.ActivityType))
|
||||
.Column<string?>(nameof(WorkflowInstanceBlockingActivitiesIndex.CorrelationId))
|
||||
.Column(nameof(WorkflowInstanceBlockingActivitiesIndex.WorkflowStatus), DbType.String)
|
||||
.Column(nameof(WorkflowInstanceBlockingActivitiesIndex.CreatedAt), DbType.DateTimeOffset),
|
||||
.Column(nameof(WorkflowInstanceBlockingActivitiesIndex.CreatedAt), DbType.DateTime),
|
||||
CollectionNames.WorkflowInstances);
|
||||
|
||||
SchemaBuilder.CreateMapIndexTable<WorkflowExecutionLogRecordIndex>(
|
||||
|
|
@ -55,7 +55,7 @@ namespace Elsa.Persistence.YesSql
|
|||
.Column<string?>(nameof(WorkflowExecutionLogRecordIndex.RecordId))
|
||||
.Column<string?>(nameof(WorkflowExecutionLogRecordIndex.TenantId))
|
||||
.Column<string>(nameof(WorkflowExecutionLogRecordIndex.WorkflowInstanceId))
|
||||
.Column(nameof(WorkflowExecutionLogRecordIndex.Timestamp), DbType.DateTimeOffset),
|
||||
.Column(nameof(WorkflowExecutionLogRecordIndex.Timestamp), DbType.DateTime),
|
||||
CollectionNames.WorkflowExecutionLog);
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -61,12 +61,24 @@ namespace Elsa.Persistence.YesSql.Stores
|
|||
|
||||
public async Task<int> DeleteManyAsync(ISpecification<T> specification, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
var documents = await Query(specification).ListAsync().ToList();
|
||||
_stopwatch.Stop();
|
||||
_logger.LogDebug("Loading documents to delete took {TimeElapsed}", _stopwatch.Elapsed);
|
||||
|
||||
foreach (var document in documents)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
Session.Delete(document, CollectionName);
|
||||
_stopwatch.Stop();
|
||||
_logger.LogDebug("Deleting document took {TimeElapsed}", _stopwatch.Elapsed);
|
||||
}
|
||||
|
||||
_stopwatch.Restart();
|
||||
await Session.CommitAsync();
|
||||
_stopwatch.Stop();
|
||||
_logger.LogDebug("Committing deleted documents took {TimeElapsed}", _stopwatch.Elapsed);
|
||||
|
||||
return documents.Count;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue