From adb322a98dddd604d69917d2980fef1359ace81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Wed, 2 Oct 2024 13:15:53 +0200 Subject: [PATCH] cleanup. --- CHANGELOG.md | 2 +- .../Services/IResourceHoldersQuerier.cs | 4 --- ...uthorizedDepositorsPageRequestValidator.cs | 4 --- ...ResourcePreferencesPageRequestValidator.cs | 4 --- ...ctionTransferValidationRequestValidator.cs | 4 --- ...eAccountAuthorizedDepositorsPageRequest.cs | 4 --- ...teAccountResourcePreferencesPageRequest.cs | 4 --- .../AffectedGlobalEntitiesProcessor.cs | 4 --- .../KeyValueStoreTotalsHistory.cs | 4 --- .../Queries/KeyValueStoreQueries.cs | 33 ++++++++----------- .../Queries/MetadataPagedQuery.cs | 5 +-- .../AccountStateQuerier.cs | 4 --- .../Services/KeyValueStoreQuerier.cs | 6 ++-- 13 files changed, 18 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3aadab3e..a420ec2a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,8 @@ Release built: _not released yet_ ### Bug fixes - - Added missing `total_count` property to `/state/validators/list` response. + ### API Changes - Restored previously removed `total_count` property to `/state/key-value-store/keys` endpoint. diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IResourceHoldersQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IResourceHoldersQuerier.cs index d3bea5d4d..52ca9bf80 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IResourceHoldersQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IResourceHoldersQuerier.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using RadixDlt.NetworkGateway.Abstractions; using System.Threading; using System.Threading.Tasks; diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountAuthorizedDepositorsPageRequestValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountAuthorizedDepositorsPageRequestValidator.cs index 99f9e9271..cc10debf3 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountAuthorizedDepositorsPageRequestValidator.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountAuthorizedDepositorsPageRequestValidator.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using FluentValidation; using RadixDlt.NetworkGateway.GatewayApiSdk.Model; diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountResourcePreferencesPageRequestValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountResourcePreferencesPageRequestValidator.cs index faba52623..ec769292a 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountResourcePreferencesPageRequestValidator.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateAccountResourcePreferencesPageRequestValidator.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using FluentValidation; using RadixDlt.NetworkGateway.GatewayApiSdk.Model; diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/TransactionTransferValidationRequestValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/TransactionTransferValidationRequestValidator.cs index d99f4d803..c1448ae9a 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/TransactionTransferValidationRequestValidator.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/TransactionTransferValidationRequestValidator.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using FluentValidation; using Microsoft.Extensions.Options; using RadixDlt.NetworkGateway.GatewayApi.Configuration; diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountAuthorizedDepositorsPageRequest.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountAuthorizedDepositorsPageRequest.cs index ee330e4d9..dbf3a5972 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountAuthorizedDepositorsPageRequest.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountAuthorizedDepositorsPageRequest.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model; public partial class StateAccountAuthorizedDepositorsPageRequest : IPaginableRequest diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountResourcePreferencesPageRequest.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountResourcePreferencesPageRequest.cs index 3ab22972a..b50c49a0e 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountResourcePreferencesPageRequest.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/StateAccountResourcePreferencesPageRequest.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model; public partial class StateAccountResourcePreferencesPageRequest : IPaginableRequest diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AffectedGlobalEntitiesProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AffectedGlobalEntitiesProcessor.cs index da223a040..14a1c1d3c 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AffectedGlobalEntitiesProcessor.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AffectedGlobalEntitiesProcessor.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using RadixDlt.NetworkGateway.Abstractions; using RadixDlt.NetworkGateway.Abstractions.Network; using RadixDlt.NetworkGateway.PostgresIntegration.Models; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyValueStore/KeyValueStoreTotalsHistory.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyValueStore/KeyValueStoreTotalsHistory.cs index 433948926..491b3b70c 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyValueStore/KeyValueStoreTotalsHistory.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyValueStore/KeyValueStoreTotalsHistory.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs index 51a7726ed..45238077e 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using Dapper; using Microsoft.EntityFrameworkCore; using RadixDlt.NetworkGateway.Abstractions; @@ -200,10 +196,7 @@ LEFT JOIN LATERAL ( entries.value, entries.is_locked, entries.is_deleted, - CASE WHEN (ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC)) = vars.page_limit OR entries.filter_out - THEN TRUE - ELSE FALSE - END AS filter_out, + ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC) = vars.page_limit OR entries.filter_out AS filter_out, CASE WHEN (ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC)) = vars.page_limit THEN definitions.cursor @@ -211,16 +204,16 @@ THEN definitions.cursor THEN ROW(definitions.key_first_seen_state_version, definitions.id - 1) END AS next_cursor_inclusive FROM ( - SELECT - d.id, - d.key, - d.cursor, - d.from_state_version AS key_first_seen_state_version, - (ROW_NUMBER() OVER (ORDER BY d.cursor DESC)) = vars.definition_read_limit AS is_last_candidate - FROM definitions_with_cursor d - WHERE d.key_value_store_entity_id = vars.key_value_store_entity_id AND ((NOT vars.use_cursor) OR d.cursor <= vars.start_cursor_inclusive) - ORDER BY d.cursor DESC - LIMIT vars.definition_read_limit + SELECT + d.id, + d.key, + d.cursor, + d.from_state_version AS key_first_seen_state_version, + (ROW_NUMBER() OVER (ORDER BY d.cursor DESC)) = vars.definition_read_limit AS is_last_candidate + FROM definitions_with_cursor d + WHERE d.key_value_store_entity_id = vars.key_value_store_entity_id AND ((NOT vars.use_cursor) OR d.cursor <= vars.start_cursor_inclusive) + ORDER BY d.cursor DESC + LIMIT vars.definition_read_limit ) definitions INNER JOIN LATERAL ( SELECT @@ -292,7 +285,7 @@ ORDER BY entries_per_entity.cursor DESC ); } - internal static async Task KeyValueStoreData( + internal static async Task KeyValueStoreDataMultiLookupQuery( ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper, Entity keyValueStoreEntity, @@ -385,7 +378,7 @@ LIMIT 1 return new GatewayModel.StateKeyValueStoreDataResponse(ledgerState, keyValueStoreEntity.Address, items); } - internal static async Task KeyValueStoreSchema( + internal static async Task KeyValueStoreSchemaLookupQuery( ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper, long keyValueStoreId, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/MetadataPagedQuery.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/MetadataPagedQuery.cs index bbe6ba040..c47992725 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/MetadataPagedQuery.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/MetadataPagedQuery.cs @@ -181,10 +181,7 @@ LEFT JOIN LATERAL ( entries.value, entries.is_locked, entries.is_deleted, - CASE WHEN (ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC)) = vars.per_entity_page_limit OR entries.filter_out - THEN TRUE - ELSE FALSE - END AS filter_out, + ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC) = vars.per_entity_page_limit OR entries.filter_out AS filter_out, CASE WHEN (ROW_NUMBER() OVER (ORDER BY definitions.cursor DESC)) = vars.per_entity_page_limit THEN definitions.cursor diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/AccountStateQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/AccountStateQuerier.cs index af3771949..a938a73fb 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/AccountStateQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/AccountStateQuerier.cs @@ -62,10 +62,6 @@ * permissions under this License. */ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - using Dapper; using Microsoft.EntityFrameworkCore; using RadixDlt.NetworkGateway.Abstractions; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs index c947bea60..13bad5903 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs @@ -108,7 +108,7 @@ public KeyValueStoreQuerier( var networkId = (await _networkConfigurationProvider.GetNetworkConfiguration(token)).Id; var keyValueStore = await _entityQuerier.GetNonVirtualEntity(_dbContext, keyValueStoreAddress, ledgerState, token); - var keyValueStoreSchema = await KeyValueStoreQueries.KeyValueStoreSchema( + var keyValueStoreSchema = await KeyValueStoreQueries.KeyValueStoreSchemaLookupQuery( _dbContext, _dapperWrapper, keyValueStore.Id, @@ -140,14 +140,14 @@ public KeyValueStoreQuerier( var networkId = (await _networkConfigurationProvider.GetNetworkConfiguration(token)).Id; var keyValueStore = await _entityQuerier.GetNonVirtualEntity(_dbContext, keyValueStoreAddress, ledgerState, token); - var keyValueStoreSchema = await KeyValueStoreQueries.KeyValueStoreSchema( + var keyValueStoreSchema = await KeyValueStoreQueries.KeyValueStoreSchemaLookupQuery( _dbContext, _dapperWrapper, keyValueStore.Id, ledgerState, token); - return await KeyValueStoreQueries.KeyValueStoreData( + return await KeyValueStoreQueries.KeyValueStoreDataMultiLookupQuery( _dbContext, _dapperWrapper, keyValueStore,