FIX: Transaction Bugs

This commit is contained in:
2025-05-03 15:47:33 +03:30
parent 35163f7ac7
commit 2e11c65b11
3 changed files with 17 additions and 1 deletions
+9 -1
View File
@@ -47,6 +47,7 @@ const createTransaction = async (data) => {
description: data.description,
userId: data.userId,
belongingId: data.belongingId,
userName: data.userName,
})
}
@@ -198,6 +199,7 @@ const indexAllTransactions = async () => {
const transactions = await Transaction.find({}, null, null)
.skip((i - 1) * batchSize)
.limit(batchSize)
.populate('belongingId')
let documents = []
@@ -206,10 +208,13 @@ const indexAllTransactions = async () => {
_id: transaction._id,
type: transaction.type,
status: transaction.status,
source: transaction.source,
source: transaction.source || '',
value: transaction.value,
description: transaction.description,
createdAt: Math.floor(new Date(transaction.createdAt).getTime() / 1000), // Store as timestamp in seconds
belongingName: transaction.belongingId.name,
belongingId: transaction.belongingId._id,
userName: transaction.userName || '',
}
documents.push(data)
@@ -233,6 +238,9 @@ const getTypeSenseSchema = () => {
{ name: 'value', type: 'int64', facet: false },
{ name: 'description', type: 'string', facet: false, infix: true },
{ name: 'createdAt', type: 'int64', facet: false },
{ name: 'belongingName', type: 'string', facet: false, infix: true },
{ name: 'belongingId', type: 'string', facet: false, infix: true },
{ name: 'userName', type: 'string', facet: false, infix: true },
],
default_sorting_field: 'createdAt',
}