feat: transactions table

This commit is contained in:
Rafael Taranto 2025-06-05 14:02:07 +01:00
parent 1ead9fe359
commit d6166ce752
29 changed files with 1204 additions and 726 deletions

View file

@ -3,6 +3,9 @@ const anonymous = require('../../../constants').anonymousCustomer
const customers = require('../../../customers')
const customerNotes = require('../../../customer-notes')
const machineLoader = require('../../../machine-loader')
const {
customers: { searchCustomers },
} = require('typesafe-db')
const addLastUsedMachineName = customer =>
(customer.lastUsedMachine
@ -20,6 +23,8 @@ const resolvers = {
customers: () => customers.getCustomersList(),
customer: (...[, { customerId }]) =>
customers.getCustomerById(customerId).then(addLastUsedMachineName),
searchCustomers: (...[, { searchTerm, limit = 20 }]) =>
searchCustomers(searchTerm, limit),
},
Mutation: {
setCustomer: (root, { customerId, customerInput }, context) => {

View file

@ -1,4 +1,3 @@
const DataLoader = require('dataloader')
const { parseAsync } = require('json2csv')
const filters = require('../../filters')
@ -8,15 +7,7 @@ const transactions = require('../../services/transactions')
const anonymous = require('../../../constants').anonymousCustomer
const logDateFormat = require('../../../logs').logDateFormat
const transactionsLoader = new DataLoader(
ids => transactions.getCustomerTransactionsBatch(ids),
{ cache: false },
)
const resolvers = {
Customer: {
transactions: parent => transactionsLoader.load(parent.id),
},
Transaction: {
isAnonymous: parent => parent.customerId === anonymous.uuid,
},
@ -32,6 +23,7 @@ const resolvers = {
txClass,
deviceId,
customerName,
customerId,
fiatCode,
cryptoCode,
toAddress,
@ -41,7 +33,7 @@ const resolvers = {
},
]
) =>
transactions.batch(
transactions.batch({
from,
until,
limit,
@ -49,13 +41,14 @@ const resolvers = {
txClass,
deviceId,
customerName,
customerId,
fiatCode,
cryptoCode,
toAddress,
status,
swept,
excludeTestingCustomers,
),
}),
transactionsCsv: (
...[
,
@ -67,6 +60,7 @@ const resolvers = {
txClass,
deviceId,
customerName,
customerId,
fiatCode,
cryptoCode,
toAddress,
@ -79,7 +73,7 @@ const resolvers = {
]
) =>
transactions
.batch(
.batch({
from,
until,
limit,
@ -87,6 +81,7 @@ const resolvers = {
txClass,
deviceId,
customerName,
customerId,
fiatCode,
cryptoCode,
toAddress,
@ -94,7 +89,7 @@ const resolvers = {
swept,
excludeTestingCustomers,
simplified,
)
})
.then(data =>
parseAsync(
logDateFormat(timezone, data, [

View file

@ -94,6 +94,13 @@ const typeDef = gql`
value: String
}
type CustomerSearchResult {
id: ID!
name: String
phone: String
email: String
}
type Query {
customers(
phone: String
@ -104,6 +111,8 @@ const typeDef = gql`
): [Customer] @auth
customer(customerId: ID!): Customer @auth
customerFilters: [Filter] @auth
searchCustomers(searchTerm: String!, limit: Int): [CustomerSearchResult]
@auth
}
type Mutation {

View file

@ -25,24 +25,21 @@ const typeDef = gql`
sendPending: Boolean
fixedFee: String
minimumTx: Float
customerId: ID
isAnonymous: Boolean
txVersion: Int!
termsAccepted: Boolean
commissionPercentage: String
rawTickerPrice: String
isPaperWallet: Boolean
customerPhone: String
customerEmail: String
customerIdCardDataNumber: String
customerIdCardDataExpiration: DateTimeISO
customerIdCardData: JSONObject
customerName: String
customerFrontCameraPath: String
customerIdCardPhotoPath: String
expired: Boolean
machineName: String
discount: Int
customerId: ID
customerPhone: String
customerEmail: String
customerIdCardData: JSONObject
customerFrontCameraPath: String
customerIdCardPhotoPath: String
txCustomerPhotoPath: String
txCustomerPhotoAt: DateTimeISO
batched: Boolean
@ -51,6 +48,12 @@ const typeDef = gql`
walletScore: Int
profit: String
swept: Boolean
status: String
paginationStats: PaginationStats
}
type PaginationStats {
totalCount: Int
}
type Filter {
@ -68,6 +71,7 @@ const typeDef = gql`
txClass: String
deviceId: String
customerName: String
customerId: ID
fiatCode: String
cryptoCode: String
toAddress: String
@ -83,6 +87,7 @@ const typeDef = gql`
txClass: String
deviceId: String
customerName: String
customerId: String
fiatCode: String
cryptoCode: String
toAddress: String