|
|
@@ -72,21 +72,27 @@ async function fetchMetaFromDoubao(imageUrl) {
|
|
|
|
|
|
|
|
|
async function run() {
|
|
|
-
|
|
|
let done = 0;
|
|
|
let duration = 0;
|
|
|
let hour, minute, second;
|
|
|
let start = Date.now();
|
|
|
|
|
|
-
|
|
|
// 筛选出所有已经ready并且还没有title的图
|
|
|
let query = { status: { $gte: 7000 }, $or: [{ copy: { $exists: false } }, { copy: null }] };
|
|
|
- let docs = await models.Art.find(query).sort({ publishTime: 'desc' });
|
|
|
|
|
|
- let total = docs.length;
|
|
|
+ let total = await models.Art.countDocuments();
|
|
|
console.log('total:', total);
|
|
|
|
|
|
- for (let doc of docs) {
|
|
|
+ models.Art
|
|
|
+ .find(query)
|
|
|
+ .sort({ publishTime: 'desc' })
|
|
|
+ .cursor()
|
|
|
+ .eachAsync(job)
|
|
|
+ .catch(err => console.error(err.message))
|
|
|
+ .then(() => require('process').exit(0))
|
|
|
+
|
|
|
+ async function job(doc) {
|
|
|
+ console.log(`process ${doc._id}`);
|
|
|
let thumbUrl = `${config.resHost}/thumbs/v2/work/320/${doc._id}.png`;
|
|
|
if (doc.hasSpecial) {
|
|
|
thumbUrl = `${config.resHost}/thumbs/v2/special/320/${doc._id}.png`;
|
|
|
@@ -126,7 +132,6 @@ async function run() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|