mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
refactor(nestjs): banking modules
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { castArray } from 'lodash';
|
||||
import { PromisePool } from '@supercharge/promise-pool';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UncategorizeBankTransactionService } from './UncategorizeBankTransaction.service';
|
||||
|
||||
@Injectable()
|
||||
export class UncategorizeBankTransactionsBulk {
|
||||
constructor(
|
||||
private readonly uncategorizeTransactionService: UncategorizeBankTransactionService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Uncategorize the given bank transactions in bulk.
|
||||
* @param {number | Array<number>} uncategorizedTransactionId
|
||||
*/
|
||||
public async uncategorizeBulk(
|
||||
uncategorizedTransactionId: number | Array<number>
|
||||
) {
|
||||
const uncategorizedTransactionIds = castArray(uncategorizedTransactionId);
|
||||
|
||||
const result = await PromisePool.withConcurrency(MIGRATION_CONCURRENCY)
|
||||
.for(uncategorizedTransactionIds)
|
||||
.process(async (_uncategorizedTransactionId: number, index, pool) => {
|
||||
await this.uncategorizeTransactionService.uncategorize(
|
||||
_uncategorizedTransactionId
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const MIGRATION_CONCURRENCY = 1;
|
||||
Reference in New Issue
Block a user