Montify: allow restarting stuck sync from UI; log sync progress
This commit is contained in:
@@ -236,9 +236,13 @@ export class MontifySyncService {
|
||||
: undefined;
|
||||
let page = 1;
|
||||
let lastPage = 1;
|
||||
this.logger.log(`Montify sync ${row.id} (${row.label}) start ${mode}${updatedAfter ? ` after ${updatedAfter}` : ''}`);
|
||||
do {
|
||||
const res = await client.listCustomers({ page, limit: CUSTOMER_PAGE_SIZE, updatedAfter });
|
||||
lastPage = res.meta.last_page;
|
||||
this.logger.log(
|
||||
`Montify sync ${row.id} page ${page}/${lastPage}: ${res.data.length} customers (total ${res.meta.total})`,
|
||||
);
|
||||
for (const customer of res.data) {
|
||||
result.customersFetched += 1;
|
||||
try {
|
||||
@@ -276,6 +280,10 @@ export class MontifySyncService {
|
||||
);
|
||||
result.finishedAt = new Date().toISOString();
|
||||
result.errors = [...missing, ...result.errors].slice(0, 50);
|
||||
this.logger.log(
|
||||
`Montify sync ${row.id} done: ${result.customersFetched} customers, ${result.ordersFetched} orders, ` +
|
||||
`${result.transactionsFetched} transactions, ${result.errors.length} errors${fatal ? ` — fatal: ${fatal}` : ''}`,
|
||||
);
|
||||
await this.prisma.montifyConnection.update({
|
||||
where: { id: row.id },
|
||||
data: {
|
||||
|
||||
@@ -321,7 +321,7 @@ onBeforeUnmount(() => {
|
||||
</UiButton>
|
||||
<UiButton
|
||||
size="sm"
|
||||
:disabled="!c.enabled || c.syncStatus === 'running'"
|
||||
:disabled="!c.enabled"
|
||||
@click="sync(c, 'incremental')"
|
||||
>
|
||||
همگامسازی
|
||||
@@ -329,7 +329,7 @@ onBeforeUnmount(() => {
|
||||
<UiButton
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
:disabled="!c.enabled || c.syncStatus === 'running'"
|
||||
:disabled="!c.enabled"
|
||||
@click="sync(c, 'full')"
|
||||
>
|
||||
همگامسازی کامل
|
||||
|
||||
Reference in New Issue
Block a user