From 064f573f64792f07b502119f7aa4a1d5ccd319e1 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Thu, 6 Jun 2024 21:09:22 +0300 Subject: [PATCH] Add more API filters --- Tzkt.Api/Controllers/OperationsController.cs | 70 +++++++++++-------- Tzkt.Api/Repositories/AccountRepository.cs | 14 ++-- .../OperationRepository.Baking.cs | 6 ++ .../OperationRepository.Delegations.cs | 6 ++ .../OperationRepository.DoubleBaking.cs | 6 ++ .../OperationRepository.DoubleEndorsing.cs | 6 ++ .../OperationRepository.DoublePreendorsing.cs | 6 ++ .../Processors/OperationsProcessor.cs | 10 +-- 8 files changed, 82 insertions(+), 42 deletions(-) diff --git a/Tzkt.Api/Controllers/OperationsController.cs b/Tzkt.Api/Controllers/OperationsController.cs index 262d5c61..f2366d10 100644 --- a/Tzkt.Api/Controllers/OperationsController.cs +++ b/Tzkt.Api/Controllers/OperationsController.cs @@ -839,6 +839,7 @@ public async Task> GetActivationsCount( /// Filters double baking operations by any of the specified fields. Example: `anyof.accuser.offender=tz1...` will return operations where `accuser` OR `offender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account. /// Filters double baking operations by accuser. Allowed fields for `.eqx` mode: `offender`. /// Filters double baking operations by offender. Allowed fields for `.eqx` mode: `accuser`. + /// Filters operations by internal TzKT id. /// Filters double baking operations by level. /// Filters double baking operations by timestamp. /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. @@ -854,6 +855,7 @@ public async Task>> GetDoubleBak AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SelectParameter select, @@ -901,7 +903,7 @@ public async Task>> GetDoubleBak #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("level", level), ("timestamp", timestamp), + ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("id", id), ("level", level), ("timestamp", timestamp), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit), ("quote", quote)); if (ResponseCache.TryGet(query, out var cached)) @@ -910,25 +912,25 @@ public async Task>> GetDoubleBak object res; if (select == null) { - res = await Operations.GetDoubleBakings(anyof, accuser, offender, level, timestamp, sort, offset, limit, quote); + res = await Operations.GetDoubleBakings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, quote); } else if (select.Values != null) { if (select.Values.Length == 1) - res = await Operations.GetDoubleBakings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values[0], quote); + res = await Operations.GetDoubleBakings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values[0], quote); else - res = await Operations.GetDoubleBakings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values, quote); + res = await Operations.GetDoubleBakings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values, quote); } else { if (select.Fields.Length == 1) - res = await Operations.GetDoubleBakings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields[0], quote); + res = await Operations.GetDoubleBakings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields[0], quote); else { res = new SelectionResponse { Cols = select.Fields, - Rows = await Operations.GetDoubleBakings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields, quote) + Rows = await Operations.GetDoubleBakings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields, quote) }; } } @@ -1000,6 +1002,7 @@ public async Task> GetDoubleBakingCount( /// Filters double endorsing operations by any of the specified fields. Example: `anyof.accuser.offender=tz1...` will return operations where `accuser` OR `offender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account. /// Filters double endorsing operations by accuser. Allowed fields for `.eqx` mode: `offender`. /// Filters double endorsing operations by offender. Allowed fields for `.eqx` mode: `accuser`. + /// Filters operations by internal TzKT id. /// Filters double endorsing operations by level. /// Filters double endorsing operations by timestamp. /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. @@ -1015,6 +1018,7 @@ public async Task>> GetDouble AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SelectParameter select, @@ -1062,7 +1066,7 @@ public async Task>> GetDouble #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("level", level), ("timestamp", timestamp), + ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("id", id), ("level", level), ("timestamp", timestamp), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit), ("quote", quote)); if (ResponseCache.TryGet(query, out var cached)) @@ -1071,25 +1075,25 @@ public async Task>> GetDouble object res; if (select == null) { - res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, quote); + res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, quote); } else if (select.Values != null) { if (select.Values.Length == 1) - res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values[0], quote); + res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values[0], quote); else - res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values, quote); + res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values, quote); } else { if (select.Fields.Length == 1) - res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields[0], quote); + res = await Operations.GetDoubleEndorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields[0], quote); else { res = new SelectionResponse { Cols = select.Fields, - Rows = await Operations.GetDoubleEndorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields, quote) + Rows = await Operations.GetDoubleEndorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields, quote) }; } } @@ -1161,6 +1165,7 @@ public async Task> GetDoubleEndorsingCount( /// Filters by any of the specified fields. Example: `anyof.accuser.offender=tz1...` will return operations where `accuser` OR `offender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account. /// Filters by accuser. Allowed fields for `.eqx` mode: `offender`. /// Filters by offender. Allowed fields for `.eqx` mode: `accuser`. + /// Filters operations by internal TzKT id. /// Filters by level. /// Filters by timestamp. /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. @@ -1176,6 +1181,7 @@ public async Task>> GetDou AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SelectParameter select, @@ -1223,7 +1229,7 @@ public async Task>> GetDou #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("level", level), ("timestamp", timestamp), + ("anyof", anyof), ("accuser", accuser), ("offender", offender), ("id", id), ("level", level), ("timestamp", timestamp), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit), ("quote", quote)); if (ResponseCache.TryGet(query, out var cached)) @@ -1232,25 +1238,25 @@ public async Task>> GetDou object res; if (select == null) { - res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, quote); + res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, quote); } else if (select.Values != null) { if (select.Values.Length == 1) - res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values[0], quote); + res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values[0], quote); else - res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Values, quote); + res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Values, quote); } else { if (select.Fields.Length == 1) - res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields[0], quote); + res = await Operations.GetDoublePreendorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields[0], quote); else { res = new SelectionResponse { Cols = select.Fields, - Rows = await Operations.GetDoublePreendorsings(anyof, accuser, offender, level, timestamp, sort, offset, limit, select.Fields, quote) + Rows = await Operations.GetDoublePreendorsings(anyof, accuser, offender, id, level, timestamp, sort, offset, limit, select.Fields, quote) }; } } @@ -1775,6 +1781,7 @@ public async Task> GetDrainDelegateOpsCount( /// Filters delegations by sender. Allowed fields for `.eqx` mode: `prevDelegate`, `newDelegate`. /// Filters delegations by prev delegate. Allowed fields for `.eqx` mode: `initiator`, `sender`, `newDelegate`. /// Filters delegations by new delegate. Allowed fields for `.eqx` mode: `initiator`, `sender`, `prevDelegate`. + /// Filters operations by internal TzKT id. /// Filters delegations by level. /// Filters delegations by timestamp. /// Filters by `senderCodeHash`. @@ -1794,6 +1801,7 @@ public async Task>> GetDelegations AccountParameter sender, AccountParameter prevDelegate, AccountParameter newDelegate, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, Int32Parameter senderCodeHash, @@ -1868,7 +1876,7 @@ public async Task>> GetDelegations var query = ResponseCacheService.BuildKey(Request.Path.Value, ("anyof", anyof), ("initiator", initiator), ("sender", sender), ("prevDelegate", prevDelegate), - ("newDelegate", newDelegate), ("level", level), ("timestamp", timestamp), ("senderCodeHash", senderCodeHash), + ("newDelegate", newDelegate), ("id", id), ("level", level), ("timestamp", timestamp), ("senderCodeHash", senderCodeHash), ("status", status), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit), ("quote", quote)); if (ResponseCache.TryGet(query, out var cached)) @@ -1877,25 +1885,25 @@ public async Task>> GetDelegations object res; if (select == null) { - res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, level, timestamp, senderCodeHash, status, sort, offset, limit, quote); + res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, id, level, timestamp, senderCodeHash, status, sort, offset, limit, quote); } else if (select.Values != null) { if (select.Values.Length == 1) - res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Values[0], quote); + res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, id, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Values[0], quote); else - res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Values, quote); + res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, id, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Values, quote); } else { if (select.Fields.Length == 1) - res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Fields[0], quote); + res = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, id, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Fields[0], quote); else { res = new SelectionResponse { Cols = select.Fields, - Rows = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Fields, quote) + Rows = await Operations.GetDelegations(anyof, initiator, sender, prevDelegate, newDelegate, id, level, timestamp, senderCodeHash, status, sort, offset, limit, select.Fields, quote) }; } } @@ -5379,6 +5387,7 @@ public async Task> GetRevelationPenaltiesCount( /// Filters by any of the specified fields. Example: `anyof.proposer.producer=tz1...`. /// Filters by block proposer. Allowed fields for `.eqx` mode: none. /// Filters by block producer. Allowed fields for `.eqx` mode: none. + /// Filters operations by internal TzKT id. /// Filters baking operations by level. /// Filters baking operations by timestamp. /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. @@ -5395,6 +5404,7 @@ public async Task>> GetBaking( AnyOfParameter anyof, AccountParameter proposer, AccountParameter producer, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SelectParameter select, @@ -5444,7 +5454,7 @@ public async Task>> GetBaking( #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("baker", baker), ("anyof", anyof), ("proposer", proposer), ("producer", producer), ("level", level), + ("baker", baker), ("anyof", anyof), ("proposer", proposer), ("producer", producer), ("id", id), ("level", level), ("timestamp", timestamp), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit), ("quote", quote)); if (ResponseCache.TryGet(query, out var cached)) @@ -5453,25 +5463,25 @@ public async Task>> GetBaking( object res; if (select == null) { - res = await Operations.GetBakings(anyof, proposer, producer, level, timestamp, sort, offset, limit, quote); + res = await Operations.GetBakings(anyof, proposer, producer, id, level, timestamp, sort, offset, limit, quote); } else if (select.Values != null) { if (select.Values.Length == 1) - res = await Operations.GetBakings(anyof, proposer, producer, level, timestamp, sort, offset, limit, select.Values[0], quote); + res = await Operations.GetBakings(anyof, proposer, producer, id, level, timestamp, sort, offset, limit, select.Values[0], quote); else - res = await Operations.GetBakings(anyof, proposer, producer, level, timestamp, sort, offset, limit, select.Values, quote); + res = await Operations.GetBakings(anyof, proposer, producer, id, level, timestamp, sort, offset, limit, select.Values, quote); } else { if (select.Fields.Length == 1) - res = await Operations.GetBakings(anyof, proposer, producer, level, timestamp, sort, offset, limit, select.Fields[0], quote); + res = await Operations.GetBakings(anyof, proposer, producer, id, level, timestamp, sort, offset, limit, select.Fields[0], quote); else { res = new SelectionResponse { Cols = select.Fields, - Rows = await Operations.GetBakings(anyof, proposer, producer, level, timestamp, sort, offset, limit, select.Fields, quote) + Rows = await Operations.GetBakings(anyof, proposer, producer, id, level, timestamp, sort, offset, limit, select.Fields, quote) }; } } diff --git a/Tzkt.Api/Repositories/AccountRepository.cs b/Tzkt.Api/Repositories/AccountRepository.cs index 7ef0d679..95f5fc1e 100644 --- a/Tzkt.Api/Repositories/AccountRepository.cs +++ b/Tzkt.Api/Repositories/AccountRepository.cs @@ -2362,15 +2362,15 @@ public async Task> GetOperations( : Task.FromResult(Enumerable.Empty()); var doubleBaking = delegat.DoubleBakingCount > 0 && types.Contains(OpTypes.DoubleBaking) - ? Operations.GetDoubleBakings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, level, timestamp, sort, offset, limit, quote) + ? Operations.GetDoubleBakings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, null, level, timestamp, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var doubleEndorsing = delegat.DoubleEndorsingCount > 0 && types.Contains(OpTypes.DoubleEndorsing) - ? Operations.GetDoubleEndorsings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, level, timestamp, sort, offset, limit, quote) + ? Operations.GetDoubleEndorsings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, null, level, timestamp, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var doublePreendorsing = delegat.DoublePreendorsingCount > 0 && types.Contains(OpTypes.DoublePreendorsing) - ? Operations.GetDoublePreendorsings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, level, timestamp, sort, offset, limit, quote) + ? Operations.GetDoublePreendorsings(new AnyOfParameter { Fields = new[] { "accuser", "offender" }, Eq = delegat.Id }, accuser, offender, null, level, timestamp, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var nonceRevelations = delegat.NonceRevelationsCount > 0 && types.Contains(OpTypes.NonceRevelation) @@ -2382,7 +2382,7 @@ public async Task> GetOperations( : Task.FromResult(Enumerable.Empty()); var delegations = delegat.DelegationsCount > 0 && types.Contains(OpTypes.Delegation) - ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = delegat.Id }, initiator, sender, prevDelegate, newDelegate, level, timestamp, null, status, sort, offset, limit, quote) + ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = delegat.Id }, initiator, sender, prevDelegate, newDelegate, null, level, timestamp, null, status, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var originations = delegat.OriginationsCount > 0 && types.Contains(OpTypes.Origination) @@ -2502,7 +2502,7 @@ public async Task> GetOperations( : Task.FromResult(Enumerable.Empty()); var bakingOps = delegat.BlocksCount > 0 && types.Contains(OpTypes.Baking) - ? Operations.GetBakings(new AnyOfParameter { Fields = new[] { "proposer", "producer" }, Eq = delegat.Id }, null, null, level, timestamp, sort, offset, limit, quote) + ? Operations.GetBakings(new AnyOfParameter { Fields = new[] { "proposer", "producer" }, Eq = delegat.Id }, null, null, null, level, timestamp, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var endorsingRewards = delegat.EndorsingRewardsCount > 0 && types.Contains(OpTypes.EndorsingReward) @@ -2611,7 +2611,7 @@ await Task.WhenAll( : Task.FromResult(Enumerable.Empty()); var userDelegations = user.DelegationsCount > 0 && types.Contains(OpTypes.Delegation) - ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = user.Id }, initiator, sender, prevDelegate, newDelegate, level, timestamp, null, status, sort, offset, limit, quote) + ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = user.Id }, initiator, sender, prevDelegate, newDelegate, null, level, timestamp, null, status, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var userOriginations = user.OriginationsCount > 0 && types.Contains(OpTypes.Origination) @@ -2788,7 +2788,7 @@ await Task.WhenAll( var _contract = new AccountParameter { Eq = contract.Id }; var contractDelegations = contract.DelegationsCount > 0 && types.Contains(OpTypes.Delegation) - ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = contract.Id }, initiator, sender, prevDelegate, newDelegate, level, timestamp, null, status, sort, offset, limit, quote) + ? Operations.GetDelegations(new AnyOfParameter { Fields = new[] { "initiator", "sender", "prevDelegate", "newDelegate" }, Eq = contract.Id }, initiator, sender, prevDelegate, newDelegate, null, level, timestamp, null, status, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); var contractOriginations = contract.OriginationsCount > 0 && types.Contains(OpTypes.Origination) diff --git a/Tzkt.Api/Repositories/OperationRepository.Baking.cs b/Tzkt.Api/Repositories/OperationRepository.Baking.cs index f05df5a7..a40c531b 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Baking.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Baking.cs @@ -58,6 +58,7 @@ public async Task> GetBakings( AnyOfParameter anyof, AccountParameter proposer, AccountParameter producer, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -70,6 +71,7 @@ public async Task> GetBakings( .Filter("ProposerId", proposer) .Filter("ProducerId", producer) .Filter(@"""ProducerId"" IS NOT NULL") + .Filter("Id", id) .Filter("Level", level) .Filter("Timestamp", timestamp) .Take(sort, offset, limit, x => x == "level" ? ("Id", "Level") : ("Id", "Id")); @@ -105,6 +107,7 @@ public async Task GetBakings( AnyOfParameter anyof, AccountParameter proposer, AccountParameter producer, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -164,6 +167,7 @@ public async Task GetBakings( .Filter("ProposerId", proposer) .Filter("ProducerId", producer) .Filter(@"""ProducerId"" IS NOT NULL") + .Filter("Id", id) .Filter("Level", level) .Filter("Timestamp", timestamp) .Take(sort, offset, limit, x => x == "level" ? ("Id", "Level") : ("Id", "Id")); @@ -284,6 +288,7 @@ public async Task GetBakings( AnyOfParameter anyof, AccountParameter proposer, AccountParameter producer, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -340,6 +345,7 @@ public async Task GetBakings( .Filter("ProposerId", proposer) .Filter("ProducerId", producer) .Filter(@"""ProducerId"" IS NOT NULL") + .Filter("Id", id) .Filter("Level", level) .Filter("Timestamp", timestamp) .Take(sort, offset, limit, x => x == "level" ? ("Id", "Level") : ("Id", "Id")); diff --git a/Tzkt.Api/Repositories/OperationRepository.Delegations.cs b/Tzkt.Api/Repositories/OperationRepository.Delegations.cs index b3ab5837..d2742a2c 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Delegations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Delegations.cs @@ -184,6 +184,7 @@ public async Task> GetDelegations( AccountParameter sender, AccountParameter prevDelegate, AccountParameter newDelegate, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, Int32Parameter senderCodeHash, @@ -205,6 +206,7 @@ public async Task> GetDelegations( .Filter("SenderId", sender, x => x == "prevDelegate" ? "PrevDelegateId" : "DelegateId") .Filter("PrevDelegateId", prevDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "DelegateId") .Filter("DelegateId", newDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "PrevDelegateId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .FilterA(@"o.""SenderCodeHash""", senderCodeHash) @@ -252,6 +254,7 @@ public async Task GetDelegations( AccountParameter sender, AccountParameter prevDelegate, AccountParameter newDelegate, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, Int32Parameter senderCodeHash, @@ -316,6 +319,7 @@ public async Task GetDelegations( .Filter("SenderId", sender, x => x == "prevDelegate" ? "PrevDelegateId" : "DelegateId") .Filter("PrevDelegateId", prevDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "DelegateId") .Filter("DelegateId", newDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "PrevDelegateId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .FilterA(@"o.""SenderCodeHash""", senderCodeHash) @@ -449,6 +453,7 @@ public async Task GetDelegations( AccountParameter sender, AccountParameter prevDelegate, AccountParameter newDelegate, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, Int32Parameter senderCodeHash, @@ -510,6 +515,7 @@ public async Task GetDelegations( .Filter("SenderId", sender, x => x == "prevDelegate" ? "PrevDelegateId" : "DelegateId") .Filter("PrevDelegateId", prevDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "DelegateId") .Filter("DelegateId", newDelegate, x => x == "initiator" ? "InitiatorId" : x == "sender" ? "SenderId" : "PrevDelegateId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .FilterA(@"o.""SenderCodeHash""", senderCodeHash) diff --git a/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs b/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs index 9716ebb7..7200e920 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs @@ -89,6 +89,7 @@ public async Task> GetDoubleBakings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -105,6 +106,7 @@ INNER JOIN "Blocks" as b .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -147,6 +149,7 @@ public async Task GetDoubleBakings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -203,6 +206,7 @@ public async Task GetDoubleBakings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -316,6 +320,7 @@ public async Task GetDoubleBakings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -369,6 +374,7 @@ public async Task GetDoubleBakings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch diff --git a/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs b/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs index c2a7fa03..a991edfa 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs @@ -89,6 +89,7 @@ public async Task> GetDoubleEndorsings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -105,6 +106,7 @@ INNER JOIN "Blocks" as b .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -147,6 +149,7 @@ public async Task GetDoubleEndorsings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -203,6 +206,7 @@ public async Task GetDoubleEndorsings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -316,6 +320,7 @@ public async Task GetDoubleEndorsings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -369,6 +374,7 @@ public async Task GetDoubleEndorsings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch diff --git a/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs b/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs index 2ff684df..50710e65 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs @@ -89,6 +89,7 @@ public async Task> GetDoublePreendorsin AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -105,6 +106,7 @@ INNER JOIN "Blocks" as b .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -147,6 +149,7 @@ public async Task GetDoublePreendorsings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -203,6 +206,7 @@ public async Task GetDoublePreendorsings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch @@ -316,6 +320,7 @@ public async Task GetDoublePreendorsings( AnyOfParameter anyof, AccountParameter accuser, AccountParameter offender, + Int64Parameter id, Int32Parameter level, DateTimeParameter timestamp, SortParameter sort, @@ -369,6 +374,7 @@ public async Task GetDoublePreendorsings( .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") + .FilterA(@"o.""Id""", id) .FilterA(@"o.""Level""", level) .FilterA(@"o.""Timestamp""", timestamp) .Take(sort, offset, limit, x => x switch diff --git a/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs b/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs index 5252149a..cec13859 100644 --- a/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs @@ -109,15 +109,15 @@ public async Task OnStateChanged() : Task.FromResult(Enumerable.Empty()); var doubleBaking = TypeSubs.TryGetValue(Operations.DoubleBakings, out var doubleBakingSub) - ? Repo.GetDoubleBakings(null, null, null, level, null, null, null, limit, symbols) + ? Repo.GetDoubleBakings(null, null, null, null, level, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); var doubleEndorsing = TypeSubs.TryGetValue(Operations.DoubleEndorsings, out var doubleEndorsingSub) - ? Repo.GetDoubleEndorsings(null, null, null, level, null, null, null, limit, symbols) + ? Repo.GetDoubleEndorsings(null, null, null, null, level, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); var doublePreendorsing = TypeSubs.TryGetValue(Operations.DoublePreendorsings, out var doublePreendorsingSub) - ? Repo.GetDoublePreendorsings(null, null, null, level, null, null, null, limit, symbols) + ? Repo.GetDoublePreendorsings(null, null, null, null, level, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); var revelations = TypeSubs.TryGetValue(Operations.Revelations, out var revelationsSub) @@ -129,7 +129,7 @@ public async Task OnStateChanged() : Task.FromResult(Enumerable.Empty()); var delegations = TypeSubs.TryGetValue(Operations.Delegations, out var delegationsSub) - ? Repo.GetDelegations(null, null, null, null, null, level, null, null, null, null, null, limit, symbols) + ? Repo.GetDelegations(null, null, null, null, null, null, level, null, null, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); var originations = TypeSubs.TryGetValue(Operations.Originations, out var originationsSub) @@ -249,7 +249,7 @@ public async Task OnStateChanged() : Task.FromResult(Enumerable.Empty()); var baking = TypeSubs.TryGetValue(Operations.Baking, out var bakingSub) - ? Repo.GetBakings(null, null, null, level, null, null, null, limit, symbols) + ? Repo.GetBakings(null, null, null, null, level, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); var endorsingRewards = TypeSubs.TryGetValue(Operations.EndorsingRewards, out var endorsingRewardsSub)