Skip to content

Commit

Permalink
Improve performance of token balances and token transfers API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Jul 1, 2022
1 parent 3cee7ee commit 92f385a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Tzkt.Api/Repositories/TokensRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async Task<IEnumerable<dynamic>> QueryTokenBalancesAsync(TokenBalanceFilter filt
tb.""LastLevel"",
tb.""TransfersCount"",
tb.""TokenId"" as ""tId"",
t.""ContractId"" as ""tContractId"",
tb.""ContractId"" as ""tContractId"",
t.""TokenId"" as ""tTokenId"",
t.""Tags"" as ""tTags"",
t.""Metadata"" as ""tMetadata""";
Expand All @@ -271,7 +271,7 @@ async Task<IEnumerable<dynamic>> QueryTokenBalancesAsync(TokenBalanceFilter filt
if (field.Path == null)
{
columns.Add(@"tb.""TokenId"" as ""tId""");
columns.Add(@"t.""ContractId"" as ""tContractId""");
columns.Add(@"tb.""ContractId"" as ""tContractId""");
columns.Add(@"t.""TokenId"" as ""tTokenId""");
columns.Add(@"t.""Tags"" as ""tTags""");
columns.Add(@"t.""Metadata"" as ""tMetadata""");
Expand All @@ -282,7 +282,7 @@ async Task<IEnumerable<dynamic>> QueryTokenBalancesAsync(TokenBalanceFilter filt
switch (subField.Field)
{
case "id": columns.Add(@"tb.""TokenId"" as ""tId"""); break;
case "contract": columns.Add(@"t.""ContractId"" as ""tContractId"""); break;
case "contract": columns.Add(@"tb.""ContractId"" as ""tContractId"""); break;
case "tokenId": columns.Add(@"t.""TokenId"" as ""tTokenId"""); break;
case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break;
case "metadata":
Expand Down Expand Up @@ -329,7 +329,7 @@ async Task<IEnumerable<dynamic>> QueryTokenBalancesAsync(TokenBalanceFilter filt
.FilterA(@"tb.""LastLevel""", filter.lastLevel)
.FilterA(@"tb.""LastLevel""", filter.lastTime)
.FilterA(@"tb.""TokenId""", filter.token.id)
.FilterA(@"t.""ContractId""", filter.token.contract)
.FilterA(@"tb.""ContractId""", filter.token.contract)
.FilterA(@"t.""TokenId""", filter.token.tokenId)
.FilterA(@"t.""Tags""", filter.token.standard)
.FilterA(@"t.""Metadata""", filter.token.metadata)
Expand Down Expand Up @@ -361,7 +361,7 @@ SELECT COUNT(*) FROM ""TokenBalances"" as tb
.FilterA(@"tb.""LastLevel""", filter.lastLevel)
.FilterA(@"tb.""LastLevel""", filter.lastTime)
.FilterA(@"tb.""TokenId""", filter.token.id)
.FilterA(@"t.""ContractId""", filter.token.contract)
.FilterA(@"tb.""ContractId""", filter.token.contract)
.FilterA(@"t.""TokenId""", filter.token.tokenId)
.FilterA(@"t.""Tags""", filter.token.standard)
.FilterA(@"t.""Metadata""", filter.token.metadata);
Expand Down Expand Up @@ -510,7 +510,7 @@ async Task<IEnumerable<dynamic>> QueryTokenTransfersAsync(TokenTransferFilter fi
tr.""OriginationId"",
tr.""MigrationId"",
tr.""TokenId"" as ""tId"",
t.""ContractId"" as ""tContractId"",
tr.""ContractId"" as ""tContractId"",
t.""TokenId"" as ""tTokenId"",
t.""Tags"" as ""tTags"",
t.""Metadata"" as ""tMetadata""";
Expand All @@ -535,7 +535,7 @@ async Task<IEnumerable<dynamic>> QueryTokenTransfersAsync(TokenTransferFilter fi
if (field.Path == null)
{
columns.Add(@"tr.""TokenId"" as ""tId""");
columns.Add(@"t.""ContractId"" as ""tContractId""");
columns.Add(@"tr.""ContractId"" as ""tContractId""");
columns.Add(@"t.""TokenId"" as ""tTokenId""");
columns.Add(@"t.""Tags"" as ""tTags""");
columns.Add(@"t.""Metadata"" as ""tMetadata""");
Expand All @@ -546,7 +546,7 @@ async Task<IEnumerable<dynamic>> QueryTokenTransfersAsync(TokenTransferFilter fi
switch (subField.Field)
{
case "id": columns.Add(@"tr.""TokenId"" as ""tId"""); break;
case "contract": columns.Add(@"t.""ContractId"" as ""tContractId"""); break;
case "contract": columns.Add(@"tr.""ContractId"" as ""tContractId"""); break;
case "tokenId": columns.Add(@"t.""TokenId"" as ""tTokenId"""); break;
case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break;
case "metadata":
Expand Down Expand Up @@ -596,7 +596,7 @@ async Task<IEnumerable<dynamic>> QueryTokenTransfersAsync(TokenTransferFilter fi
.FilterA(@"tr.""OriginationId""", filter.originationId)
.FilterA(@"tr.""MigrationId""", filter.migrationId)
.FilterA(@"tr.""TokenId""", filter.token.id)
.FilterA(@"t.""ContractId""", filter.token.contract)
.FilterA(@"tr.""ContractId""", filter.token.contract)
.FilterA(@"t.""TokenId""", filter.token.tokenId)
.FilterA(@"t.""Tags""", filter.token.standard)
.FilterA(@"t.""Metadata""", filter.token.metadata)
Expand Down Expand Up @@ -629,7 +629,7 @@ SELECT COUNT(*) FROM ""TokenTransfers"" as tr
.FilterA(@"tr.""OriginationId""", filter.originationId)
.FilterA(@"tr.""MigrationId""", filter.migrationId)
.FilterA(@"tr.""TokenId""", filter.token.id)
.FilterA(@"t.""ContractId""", filter.token.contract)
.FilterA(@"tr.""ContractId""", filter.token.contract)
.FilterA(@"t.""TokenId""", filter.token.tokenId)
.FilterA(@"t.""Tags""", filter.token.standard)
.FilterA(@"t.""Metadata""", filter.token.metadata);
Expand Down

0 comments on commit 92f385a

Please sign in to comment.