-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add invoice pagination to account and wallet gql objects
- Loading branch information
1 parent
94d275e
commit 6232ee2
Showing
31 changed files
with
1,173 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getInvoicesForWallets } from "../wallets" | ||
|
||
import { RepositoryError } from "@/domain/errors" | ||
import { WalletsRepository } from "@/services/mongoose" | ||
|
||
export const getInvoicesForAccountByWalletIds = async ({ | ||
account, | ||
walletIds, | ||
rawPaginationArgs, | ||
}: { | ||
account: Account | ||
walletIds?: WalletId[] | ||
rawPaginationArgs: { | ||
first?: number | null | ||
last?: number | null | ||
before?: string | null | ||
after?: string | null | ||
} | ||
}): Promise<PaginatedQueryResult<WalletInvoice> | ApplicationError> => { | ||
const walletsRepo = WalletsRepository() | ||
|
||
const accountWallets = await walletsRepo.listByAccountId(account.id) | ||
if (accountWallets instanceof RepositoryError) return accountWallets | ||
|
||
const wallets = accountWallets.filter((wallet) => | ||
walletIds ? walletIds.includes(wallet.id) : true, | ||
) | ||
|
||
return getInvoicesForWallets({ wallets, rawPaginationArgs }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { MAX_PAGINATION_PAGE_SIZE } from "@/config" | ||
import { checkedToPaginatedQueryArgs } from "@/domain/primitives" | ||
import { WalletInvoicesRepository } from "@/services/mongoose" | ||
|
||
export const getInvoicesForWallets = async ({ | ||
wallets, | ||
rawPaginationArgs, | ||
}: { | ||
wallets: Wallet[] | ||
rawPaginationArgs: { | ||
first?: number | null | ||
last?: number | null | ||
before?: string | null | ||
after?: string | null | ||
} | ||
}): Promise<PaginatedQueryResult<WalletInvoice> | ApplicationError> => { | ||
const walletIds = wallets.map((wallet) => wallet.id) | ||
|
||
const paginationArgs = checkedToPaginatedQueryArgs({ | ||
paginationArgs: rawPaginationArgs, | ||
maxPageSize: MAX_PAGINATION_PAGE_SIZE, | ||
}) | ||
|
||
if (paginationArgs instanceof Error) { | ||
return paginationArgs | ||
} | ||
|
||
return WalletInvoicesRepository().findInvoicesForWallets({ | ||
walletIds, | ||
paginationArgs, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.