Merge pull request 'feat:' (#65) from fix/bug-firman into development
continuous-integration/drone/tag Build is passing Details

Reviewed-on: #65
pull/66/head 20.1.30-alpha.1
firmanr 2024-08-12 09:18:08 +00:00
commit c98b8da9ba
2 changed files with 25 additions and 4 deletions

View File

@ -3,7 +3,7 @@ import { DatabaseListen } from '../../constants';
import { EventBus } from '@nestjs/cqrs';
import { ChangeDocEvent } from '../../domain/events/change-doc.event';
import { ConfigService } from '@nestjs/config';
import { apm } from 'src/core/apm';
import * as Nano from 'nano';
@Injectable()
@ -49,7 +49,10 @@ export class CouchService {
const nano = this.nanoInstance;
const db = nano.use(database);
return await db.insert(data);
} catch (error) {}
} catch (error) {
console.log(error);
apm.captureError(error);
}
}
public async deleteDoc(data, database) {
@ -58,7 +61,10 @@ export class CouchService {
const db = nano.use(database);
const result = await db.get(data.id);
await db.destroy(data.id, result._rev);
} catch (error) {}
} catch (error) {
console.log(error);
apm.captureError(error);
}
}
public async updateDoc(data, database) {
@ -70,7 +76,10 @@ export class CouchService {
...data,
_rev: result._rev,
});
} catch (error) {}
} catch (error) {
console.log(error);
apm.captureError(error);
}
}
public async getDoc(id: string, database: string) {
@ -80,6 +89,8 @@ export class CouchService {
const result = await db.get(id);
return result;
} catch (error) {
console.log(error);
apm.captureError(error);
return null;
}
}

View File

@ -11,6 +11,7 @@ import { TransactionChangeStatusEvent } from '../../entities/event/transaction-c
import * as _ from 'lodash';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { generateInvoiceCodeHelper } from '../managers/helpers/generate-invoice-code.helper';
import { apm } from 'src/core/apm';
@EventsHandler(MidtransCallbackEvent)
export class MidtransCallbackHandler
@ -22,6 +23,11 @@ export class MidtransCallbackHandler
) {}
async handle(event: MidtransCallbackEvent) {
const apmTransactions = apm.startTransaction(
`callback-midtrans`,
'handler',
);
const data_id = event.data.id;
const data = event.data.data;
let old_data = undefined;
@ -33,6 +39,8 @@ export class MidtransCallbackHandler
});
old_data = _.cloneDeep(transaction);
apmTransactions.setLabel('status', data.transaction_status);
if (['capture', 'settlement'].includes(data.transaction_status)) {
Object.assign(transaction, {
status: STATUS.SETTLED,
@ -69,5 +77,7 @@ export class MidtransCallbackHandler
op: OPERATION.UPDATE,
}),
);
apmTransactions.end();
}
}