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