| | | 1 | | namespace Services.SearchServices.OrderSearch; |
| | | 2 | | |
| | | 3 | | public enum OrderSearchIndexOperation |
| | | 4 | | { |
| | | 5 | | Single, |
| | | 6 | | Bulk, |
| | | 7 | | IncrementalBatch, |
| | | 8 | | FullReindex, |
| | | 9 | | Delete, |
| | | 10 | | DriftRepair |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | public sealed class OrderSearchIndexEvent |
| | | 14 | | { |
| | | 15 | | public Guid Id { get; init; } = Guid.NewGuid(); |
| | | 16 | | |
| | | 17 | | public DateTime TimestampUtc { get; init; } = DateTime.UtcNow; |
| | | 18 | | |
| | | 19 | | public OrderSearchIndexOperation Operation { get; init; } |
| | | 20 | | |
| | | 21 | | public int? OrderId { get; init; } |
| | | 22 | | |
| | | 23 | | public int Count { get; init; } |
| | | 24 | | |
| | | 25 | | public long DurationMs { get; init; } |
| | | 26 | | |
| | | 27 | | public bool Success { get; init; } |
| | | 28 | | |
| | | 29 | | public string Message { get; init; } = string.Empty; |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public sealed class OrderSearchQueryEvent |
| | | 33 | | { |
| | | 34 | | public Guid Id { get; init; } = Guid.NewGuid(); |
| | | 35 | | |
| | | 36 | | public DateTime TimestampUtc { get; init; } = DateTime.UtcNow; |
| | | 37 | | |
| | | 38 | | public string? SearchText { get; init; } |
| | | 39 | | |
| | | 40 | | public string FilterSummary { get; init; } = string.Empty; |
| | | 41 | | |
| | | 42 | | public long DurationMs { get; init; } |
| | | 43 | | |
| | | 44 | | public int ResultCount { get; init; } |
| | | 45 | | |
| | | 46 | | public long? TotalHits { get; init; } |
| | | 47 | | |
| | | 48 | | public bool Truncated { get; init; } |
| | | 49 | | |
| | | 50 | | /// <summary>ResultCount ≥ порога или обрезка по MaxResults — для подсветки в JobLogs.</summary> |
| | | 51 | | public bool IsLargeResult { get; init; } |
| | | 52 | | |
| | | 53 | | public bool UsedFallback { get; init; } |
| | | 54 | | |
| | | 55 | | public string Source { get; init; } = "Orders"; |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | public sealed class OrderSearchDriftEvent |
| | | 59 | | { |
| | | 60 | | public Guid Id { get; init; } = Guid.NewGuid(); |
| | | 61 | | |
| | | 62 | | public DateTime TimestampUtc { get; init; } = DateTime.UtcNow; |
| | | 63 | | |
| | | 64 | | public string Trigger { get; init; } = string.Empty; |
| | | 65 | | |
| | | 66 | | public long IndexCount { get; init; } |
| | | 67 | | |
| | | 68 | | public long DbOrderCount { get; init; } |
| | | 69 | | |
| | | 70 | | public long AbsoluteDrift { get; init; } |
| | | 71 | | |
| | | 72 | | public int AlertThreshold { get; init; } |
| | | 73 | | |
| | | 74 | | public bool IsAlert { get; init; } |
| | | 75 | | |
| | | 76 | | public string Message { get; init; } = string.Empty; |
| | | 77 | | } |
| | | 78 | | |
| | | 79 | | public sealed class OrderSearchDriftRepairResult |
| | | 80 | | { |
| | 8 | 81 | | public bool Skipped { get; init; } |
| | | 82 | | |
| | 12 | 83 | | public string Trigger { get; init; } = string.Empty; |
| | | 84 | | |
| | 20 | 85 | | public string Message { get; init; } = string.Empty; |
| | | 86 | | |
| | 3 | 87 | | public long IndexCountBefore { get; init; } |
| | | 88 | | |
| | 3 | 89 | | public long DbOrderCountBefore { get; init; } |
| | | 90 | | |
| | 3 | 91 | | public long AbsoluteDriftBefore { get; init; } |
| | | 92 | | |
| | 5 | 93 | | public int IndexedMissing { get; init; } |
| | | 94 | | |
| | 5 | 95 | | public int DeletedOrphans { get; init; } |
| | | 96 | | |
| | 3 | 97 | | public long IndexCountAfter { get; init; } |
| | | 98 | | |
| | 3 | 99 | | public long DbOrderCountAfter { get; init; } |
| | | 100 | | |
| | 4 | 101 | | public long AbsoluteDriftAfter { get; init; } |
| | | 102 | | |
| | 5 | 103 | | public bool IsAlertAfter { get; init; } |
| | | 104 | | } |
| | | 105 | | |
| | | 106 | | public sealed class OrderSearchDiagnosticsSnapshot |
| | | 107 | | { |
| | | 108 | | public bool EsEnabled { get; init; } |
| | | 109 | | |
| | | 110 | | public string EsUrl { get; init; } = string.Empty; |
| | | 111 | | |
| | | 112 | | public string IndexName { get; init; } = "orders"; |
| | | 113 | | |
| | | 114 | | public bool IndexExists { get; init; } |
| | | 115 | | |
| | | 116 | | public long IndexCount { get; init; } |
| | | 117 | | |
| | | 118 | | public long DbOrderCount { get; init; } |
| | | 119 | | |
| | | 120 | | public long CountDrift { get; init; } |
| | | 121 | | |
| | | 122 | | public int DriftAlertThreshold { get; init; } |
| | | 123 | | |
| | | 124 | | public bool IsDriftAlert { get; init; } |
| | | 125 | | |
| | | 126 | | public DateTime? LastDriftCheckAt { get; init; } |
| | | 127 | | |
| | | 128 | | public DateTime? LastSyncedAt { get; init; } |
| | | 129 | | |
| | | 130 | | public DateTime? LastFullReindexAt { get; init; } |
| | | 131 | | |
| | | 132 | | public double AvgSearchMs { get; init; } |
| | | 133 | | |
| | | 134 | | public long MaxSearchMs { get; init; } |
| | | 135 | | |
| | | 136 | | public int SearchSampleCount { get; init; } |
| | | 137 | | |
| | | 138 | | public IReadOnlyList<OrderSearchIndexEvent> IndexEvents { get; init; } = Array.Empty<OrderSearchIndexEvent>(); |
| | | 139 | | |
| | | 140 | | public IReadOnlyList<OrderSearchQueryEvent> SearchEvents { get; init; } = Array.Empty<OrderSearchQueryEvent>(); |
| | | 141 | | |
| | | 142 | | public IReadOnlyList<OrderSearchDriftEvent> DriftEvents { get; init; } = Array.Empty<OrderSearchDriftEvent>(); |
| | | 143 | | } |
| | | 144 | | |
| | | 145 | | public sealed class OrderSearchLookupResult |
| | | 146 | | { |
| | | 147 | | public int OrderId { get; init; } |
| | | 148 | | |
| | | 149 | | public bool InIndex { get; init; } |
| | | 150 | | |
| | | 151 | | public bool InDatabase { get; init; } |
| | | 152 | | |
| | | 153 | | public OrderSearchDocument? Document { get; init; } |
| | | 154 | | |
| | | 155 | | public string? DbShipmentNumber { get; init; } |
| | | 156 | | |
| | | 157 | | public string? DbArticle { get; init; } |
| | | 158 | | |
| | | 159 | | public DateTime? DbUpdatedAt { get; init; } |
| | | 160 | | } |
| | | 161 | | |
| | | 162 | | public sealed class OrderSearchLookupResponse |
| | | 163 | | { |
| | | 164 | | public string QueryLabel { get; init; } = string.Empty; |
| | | 165 | | |
| | | 166 | | public IReadOnlyList<OrderSearchLookupResult> Items { get; init; } = Array.Empty<OrderSearchLookupResult>(); |
| | | 167 | | } |