some fixes

This commit is contained in:
2022-01-06 17:03:05 +01:00
parent 4579b52b0e
commit 9f4db03614
9 changed files with 99 additions and 19 deletions
@@ -1,4 +1,6 @@
using FluentValidation.Results;
using Raven.Client.Documents;
using Raven.Client.Documents.Linq;
namespace zero.Configuration;
@@ -31,6 +33,36 @@ public class IntegrationStore : IIntegrationStore
}
/// <inheritdoc />
public async Task<IList<Integration>> LoadByTag(string tag)
{
IEnumerable<IntegrationType> types = IntegrationTypes.GetByTag(tag);
if (!types.Any())
{
return new List<Integration>();
}
string[] aliases = types.Select(x => x.Alias).ToArray();
return await Operations.Session.Query<Integration>().Where(x => x.Flavor.In(aliases)).ToListAsync();
}
/// <inheritdoc />
public async Task<bool> Any(string tag)
{
IEnumerable<IntegrationType> types = IntegrationTypes.GetByTag(tag);
if (!types.Any())
{
return false;
}
string[] aliases = types.Select(x => x.Alias).ToArray();
return await Operations.Session.Query<Integration>().AnyAsync(x => x.Flavor.In(aliases) && x.IsActive);
}
/// <inheritdoc />
public virtual string GetChangeToken(Integration model) => Operations.GetChangeToken(model);
@@ -130,6 +162,16 @@ public interface IIntegrationStore
/// </summary>
Task<Integration> Load(string alias);
/// <summary>
/// Get all integrations by a certain tag
/// </summary>
Task<IList<Integration>> LoadByTag(string tag);
/// <summary>
/// Check if there are any activated integrations for a certain tag
/// </summary>
Task<bool> Any(string tag);
/// <summary>
/// Get the change vector for a model (Proxy to IAsyncDocumentSession.GetChangeVectorFor<>)
/// </summary>