Fix incorrect successful and failed counter of imported urls in the importer

This commit is contained in:
Hongbo Wu 2023-04-17 10:24:46 +08:00
parent 90e3c113f6
commit 11538347af
2 changed files with 11 additions and 15 deletions

View file

@ -17,7 +17,6 @@ export const importCsv = async (ctx: ImportContext, stream: Stream) => {
// labels follows format: "[label1, label2]"
const labels = row.length > 2 ? row[2].slice(1, -1).split(',') : undefined
await ctx.urlHandler(ctx, url, state, labels)
ctx.countImported += 1
} catch (error) {
console.log('invalid url', row, error)
ctx.countFailed += 1

View file

@ -1,17 +1,15 @@
import { Storage } from '@google-cloud/storage'
import { importCsv } from './csv'
import * as path from 'path'
import { importMatterArchive } from './matterHistory'
import { Stream } from 'node:stream'
import { v4 as uuid } from 'uuid'
import { CONTENT_FETCH_URL, createCloudTask, emailUserUrl } from './task'
import axios from 'axios'
import { promisify } from 'util'
import * as jwt from 'jsonwebtoken'
import { Readability } from '@omnivore/readability'
import * as Sentry from '@sentry/serverless'
import axios from 'axios'
import * as jwt from 'jsonwebtoken'
import { Stream } from 'node:stream'
import * as path from 'path'
import { promisify } from 'util'
import { v4 as uuid } from 'uuid'
import { importCsv } from './csv'
import { importMatterArchive } from './matterHistory'
import { CONTENT_FETCH_URL, createCloudTask, emailUserUrl } from './task'
export enum ArticleSavingRequestStatus {
Failed = 'FAILED',
@ -157,11 +155,10 @@ const urlHandler = async (
state,
labels
)
if (result) {
ctx.countImported += 1
}
result ? ctx.countImported++ : ctx.countFailed++
} catch (err) {
console.log('error importing url', err)
ctx.countFailed += 1
}
}