Skip to content

Commit

Permalink
Merge pull request #304 from louisaxel-ambroise/fix-subscriptions
Browse files Browse the repository at this point in the history
Fix subscriptions
  • Loading branch information
louisaxel-ambroise authored Feb 10, 2023
2 parents 0be250a + e1fb221 commit b15679f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/FasTnT.Application/Database/EpcisModelConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FasTnT.Application.Database;
using FasTnT.Domain.Model;
using FasTnT.Domain.Model.CustomQueries;
using FasTnT.Domain.Model.Events;
using FasTnT.Domain.Model.Masterdata;
using FasTnT.Domain.Model.Queries;
Expand Down Expand Up @@ -279,7 +278,7 @@ public static void Apply(ModelBuilder modelBuilder)
subscription.OwnsMany(x => x.Parameters, c =>
{
c.ToTable("SubscriptionParameter", Subscriptions);
c.Property<int>("SubscriptionId").IsRequired(true);
c.WithOwner().HasForeignKey("SubscriptionId");
c.HasKey("SubscriptionId", nameof(QueryParameter.Name));
c.Property(x => x.Values).IsRequired(false).HasJsonArrayConversion();
c.Property(x => x.Name).HasMaxLength(256).IsRequired(true);
Expand Down Expand Up @@ -310,8 +309,8 @@ public static void Apply(ModelBuilder modelBuilder)
storedQuery.OwnsMany(x => x.Parameters, c =>
{
c.ToTable("StoredQueryParameter", Queries);
c.Property<int>("QueryId");
c.HasKey("QueryId", nameof(StoredQueryParameter.Name));
c.WithOwner().HasForeignKey("QueryId");
c.HasKey("QueryId", nameof(QueryParameter.Name));
c.Property(x => x.Values).IsRequired(false).HasJsonArrayConversion();
c.Property(x => x.Name).HasMaxLength(256).IsRequired(true);
});
Expand Down
1 change: 0 additions & 1 deletion src/FasTnT.Application/Handlers/QueriesHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FasTnT.Application.Database;
using FasTnT.Application.Services.Users;
using FasTnT.Domain.Exceptions;
using FasTnT.Domain.Model.CustomQueries;
using FasTnT.Domain.Model.Queries;
using FasTnT.Domain.Model.Subscriptions;
using Microsoft.EntityFrameworkCore;
Expand Down
1 change: 0 additions & 1 deletion src/FasTnT.Application/Handlers/SubscriptionsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public async Task<Subscription> GetSubscriptionDetailsAsync(string name, Cancell
var subscription = await _context.Set<Subscription>()
.AsNoTracking()
.Where(x => x.Name == name)
.Include(x => x.Parameters)
.FirstOrDefaultAsync(x => x.Name == name, cancellationToken);

if (subscription is null)
Expand Down
3 changes: 3 additions & 0 deletions src/FasTnT.Domain/FasTnT.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<LangVersion>10</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Folder Include="Model\CustomQueries\" />
</ItemGroup>
</Project>
8 changes: 0 additions & 8 deletions src/FasTnT.Domain/Model/CustomQueries/StoredQueryParameter.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace FasTnT.Domain.Model.CustomQueries;
namespace FasTnT.Domain.Model.Queries;

public class StoredQuery
{
public int Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
public List<StoredQueryParameter> Parameters { get; set; } = new();
public List<QueryParameter> Parameters { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FasTnT.Domain.Model.CustomQueries;
using FasTnT.Domain.Model.Queries;
using FasTnT.Domain.Model.Subscriptions;
using FasTnT.Host.Features.v2_0.Subscriptions;
using System.Text.Json;
Expand Down Expand Up @@ -51,9 +51,9 @@ private static SubscriptionSchedule ParseSubscriptionSchedule(JsonElement jsonEl
};
}

private static List<StoredQueryParameter> ParseQueryParameters(JsonElement jsonElement)
private static List<QueryParameter> ParseQueryParameters(JsonElement jsonElement)
{
var parameters = new List<StoredQueryParameter>();
var parameters = new List<QueryParameter>();

if (jsonElement.ValueKind == JsonValueKind.Object)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FasTnT.Domain.Model.CustomQueries;
using FasTnT.Domain.Model.Queries;
using FasTnT.Host.Features.v2_0.Communication.Json.Parsers;

namespace FasTnT.Host.Features.v2_0.Endpoints.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using FasTnT.Application.Handlers;
using FasTnT.Application.Services.Users;
using FasTnT.Application.Tests.Context;
using FasTnT.Domain.Model.CustomQueries;
using FasTnT.Domain.Model.Queries;

namespace FasTnT.Application.Tests.Queries;
Expand Down

0 comments on commit b15679f

Please sign in to comment.