Update requestCommunityInfo to use shard info if available

By calling the new fetchCommunity procedure with Shard info or nil if
passed values are -1.
This commit is contained in:
Teodor M. Ionita 2023-11-01 17:19:42 +02:00
parent 3030a689d8
commit 0bacd54ec7
No known key found for this signature in database
GPG Key ID: 062D853392376829
1 changed files with 18 additions and 6 deletions

View File

@ -433,12 +433,24 @@ proc collectCommunityMetrics*(communityId: string, metricsType: int, intervals:
"intervals": intervals
}])
proc requestCommunityInfo*(communityId: string, tryDatabase: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("fetchCommunity".prefix, %*[{
"communityKey": communityId,
"tryDatabase": tryDatabase,
"waitForResponse": true
}])
proc requestCommunityInfo*(communityId: string, tryDatabase: bool, shardCluster: int = -1, shardIndex: int = -1): RpcResponse[JsonNode] {.raises: [Exception].} =
var shardAvailable = true
if (shardCluster == -1 or shardIndex == -1):
shardAvailable = false
if shardAvailable:
result = callPrivateRPC("fetchCommunity".prefix, %*[{
"communityKey": communityId,
"shard": {"cluster": shardCluster, "index": shardIndex },
"tryDatabase": tryDatabase,
"waitForResponse": true
}])
else:
result = callPrivateRPC("fetchCommunity".prefix, %*[{
"communityKey": communityId,
"shard": nil,
"tryDatabase": tryDatabase,
"waitForResponse": true
}])
proc importCommunity*(communityKey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("importCommunity".prefix, %*[communityKey])