version-0.1 (#1)
Squash and merge of version-0.1 Co-authored-by: James Wampler <james@wamp.dev> Co-committed-by: James Wampler <james@wamp.dev>
This commit was merged in pull request #1.
This commit is contained in:
22
src/api/MicCheck.Api/Segments/SegmentService.cs
Normal file → Executable file
22
src/api/MicCheck.Api/Segments/SegmentService.cs
Normal file → Executable file
@@ -5,15 +5,9 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MicCheck.Api.Segments;
|
||||
|
||||
public record SegmentConditionDefinition(
|
||||
string Property,
|
||||
SegmentConditionOperator Operator,
|
||||
string Value);
|
||||
public record SegmentConditionDefinition(string Property, SegmentConditionOperator Operator, string Value);
|
||||
|
||||
public record SegmentRuleDefinition(
|
||||
SegmentRuleType Type,
|
||||
IReadOnlyList<SegmentConditionDefinition> Conditions,
|
||||
IReadOnlyList<SegmentRuleDefinition>? ChildRules = null);
|
||||
public record SegmentRuleDefinition(SegmentRuleType Type, IReadOnlyList<SegmentConditionDefinition> Conditions, IReadOnlyList<SegmentRuleDefinition>? ChildRules = null);
|
||||
|
||||
public class SegmentService(MicCheckDbContext db, AuditService auditService)
|
||||
{
|
||||
@@ -37,11 +31,7 @@ public class SegmentService(MicCheckDbContext db, AuditService auditService)
|
||||
.FirstOrDefaultAsync(s => s.Id == id, ct);
|
||||
}
|
||||
|
||||
public async Task<Segment> CreateAsync(
|
||||
int projectId,
|
||||
string name,
|
||||
IReadOnlyList<SegmentRuleDefinition> rules,
|
||||
CancellationToken ct = default)
|
||||
public async Task<Segment> CreateAsync(int projectId, string name, IReadOnlyList<SegmentRuleDefinition> rules, CancellationToken ct = default)
|
||||
{
|
||||
var count = await db.Segments.CountAsync(s => s.ProjectId == projectId, ct);
|
||||
if (count >= MaxSegmentsPerProject)
|
||||
@@ -75,11 +65,7 @@ public class SegmentService(MicCheckDbContext db, AuditService auditService)
|
||||
return segment;
|
||||
}
|
||||
|
||||
public async Task<Segment> UpdateAsync(
|
||||
int id,
|
||||
string name,
|
||||
IReadOnlyList<SegmentRuleDefinition> rules,
|
||||
CancellationToken ct = default)
|
||||
public async Task<Segment> UpdateAsync(int id, string name, IReadOnlyList<SegmentRuleDefinition> rules, CancellationToken ct = default)
|
||||
{
|
||||
var segment = await db.Segments
|
||||
.Include(s => s.Rules)
|
||||
|
||||
Reference in New Issue
Block a user