fix(deployment): implement countByOwner method and corresponding tests#2763
fix(deployment): implement countByOwner method and corresponding tests#2763
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds DeploymentRepository.countByOwner(owner, status?) for owner+status counting and refactors DeploymentReaderService.listWithResources to use that repository count, parallelize lease/provider/count fetches with Promise.all, and source total count from the repository instead of HTTP pagination. Changes
Sequence DiagramsequenceDiagram
actor Client
participant DRS as DeploymentReaderService
participant HTTP as DeploymentHttpService
participant LHS as LeaseHttpService
participant Repo as DeploymentRepository
participant DB as Database
Client->>DRS: listWithResources(owner, status, skip, limit)
Note over DRS: Start Promise.all for 3 concurrent operations
par Lease fetch
DRS->>LHS: getList(...)
LHS-->>DRS: leaseList
and Deployment list & providers
DRS->>HTTP: getList(..., countTotal=false)
HTTP-->>DRS: deploymentList
alt deploymentList not empty
DRS->>HTTP: getProviders(...)
HTTP-->>DRS: providerList
end
and Count fetch
DRS->>Repo: countByOwner(owner, status)
Repo->>DB: Deployment.count(where)
DB-->>Repo: count
Repo-->>DRS: count
end
DRS->>DRS: map deployments with owner/dseq
DRS-->>Client: { deployments, count, leases, providers? }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
|
I believe that requesting data from 1 source and pagination from another would cause another set of issues eventually. Switching entirely to the indexer is obviously not an option too due to performance issues. Why can't this be fixed on the rpc node? Have this been requested to @akash-network/core ? |
5ead5d0 to
44f0bc2
Compare
|
The hybrid approach (RPC for deployments, DB for count) is intentional because This happens with both offset-based and key-based pagination, regardless of whether Since we can't get an accurate total count from the RPC, the DB count is the only viable option for pagination. This should probably also be reported to @akash-network/node as a node-level bug. |
|
@baktun14 let's first escalate this to to @akash-network/core, see how fast we can get this fixed. Coz it forces us to apply this hack which is not ideal also |
|
Hey! In regard to the One possible solution could be to offer an "infinite scroll" UX where scrolling down queries the next batch of n deployments. This way we don't need to hack and it might be a good compromise given the cost/benefit of pagination in this specific view. Thoughts? |
I don't think this is a good solution for pagination ui's when displaying with a table, which is what we use everywhere. What is the issue and why can't it be fixed? |
Why
The deployments table at stats.akash.network/addresses/{address}/deployments shows "Page 1 of 1" even when an address has many deployments. The Cosmos SDK node returns an incorrect pagination.total value equal
to the page size (e.g. "10") instead of the true total count, resulting in pageCount = ceil(10/10) = 1 and making pagination navigation impossible.
https://stats.akash.network/addresses/akash10lq8uyfl52d6t467qmd58e7jzl9ecmvet2m57p/deployments
What
Summary by CodeRabbit
New Features
Tests
Chores