mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Replaced Bluebird Promise.mapSeries
with sequence util (#17008)
refs https://github.com/TryGhost/Ghost/issues/14882 Co-authored-by: Princi Vershwal <princi.vershwal@Princis-MacBook-Pro.local>
This commit is contained in:
parent
f87dc8f5eb
commit
308a3b286a
4 changed files with 14 additions and 14 deletions
|
@ -1,8 +1,8 @@
|
|||
const Promise = require('bluebird');
|
||||
const events = require('../../../lib/common/events');
|
||||
const localUtils = require('../utils');
|
||||
const PostScheduler = require('./PostScheduler');
|
||||
const getSchedulerIntegration = require('./scheduler-intergation');
|
||||
const {sequence} = require('@tryghost/promise');
|
||||
|
||||
/**
|
||||
* @description Load all scheduled posts/pages from database.
|
||||
|
@ -13,7 +13,7 @@ const loadScheduledResources = async function () {
|
|||
const SCHEDULED_RESOURCES = ['post', 'page'];
|
||||
|
||||
// Fetches all scheduled resources(posts/pages) with default API
|
||||
const results = await Promise.mapSeries(SCHEDULED_RESOURCES, async (resourceType) => {
|
||||
const results = await sequence(SCHEDULED_RESOURCES.map(resourceType => async () => {
|
||||
const result = await api.schedules.getScheduled.query({
|
||||
options: {
|
||||
resource: resourceType
|
||||
|
@ -21,7 +21,7 @@ const loadScheduledResources = async function () {
|
|||
});
|
||||
|
||||
return result[resourceType] || [];
|
||||
});
|
||||
}));
|
||||
|
||||
return SCHEDULED_RESOURCES.reduce(function (obj, entry, index) {
|
||||
return Object.assign(obj, {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const _ = require('lodash');
|
||||
const Promise = require('bluebird');
|
||||
const db = require('../../data/db');
|
||||
const commands = require('../schema').commands;
|
||||
const ghostVersion = require('@tryghost/version');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const errors = require('@tryghost/errors');
|
||||
const {sequence} = require('@tryghost/promise');
|
||||
|
||||
const messages = {
|
||||
errorExportingData: 'Error exporting data'
|
||||
|
@ -36,9 +36,9 @@ const doExport = async function doExport(options) {
|
|||
try {
|
||||
const tables = await commands.getTables(options.transacting);
|
||||
|
||||
const tableData = await Promise.mapSeries(tables, function (tableName) {
|
||||
const tableData = await sequence(tables.map(tableName => async () => {
|
||||
return exportTable(tableName, options);
|
||||
});
|
||||
}));
|
||||
|
||||
const exportData = {
|
||||
meta: {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const Promise = require('bluebird');
|
||||
const commands = require('../../schema').commands;
|
||||
const schema = require('../../schema').tables;
|
||||
const logging = require('@tryghost/logging');
|
||||
const schemaTables = Object.keys(schema);
|
||||
const {sequence} = require('@tryghost/promise');
|
||||
|
||||
module.exports.up = async (options) => {
|
||||
const connection = options.connection;
|
||||
|
@ -10,10 +10,10 @@ module.exports.up = async (options) => {
|
|||
const existingTables = await commands.getTables(connection);
|
||||
const missingTables = schemaTables.filter(t => !existingTables.includes(t));
|
||||
|
||||
await Promise.mapSeries(missingTables, async (table) => {
|
||||
await sequence(missingTables.map(table => async () => {
|
||||
logging.info('Creating table: ' + table);
|
||||
await commands.createTable(table, connection);
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -24,9 +24,9 @@ module.exports.up = async (options) => {
|
|||
|
||||
// Reference between tables!
|
||||
schemaTables.reverse();
|
||||
await Promise.mapSeries(schemaTables, async (table) => {
|
||||
await sequence(schemaTables.map(table => async () => {
|
||||
logging.info('Drop table: ' + table);
|
||||
await commands.deleteTable(table, connection);
|
||||
});
|
||||
}));
|
||||
};
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const _ = require('lodash');
|
||||
const should = require('should');
|
||||
const supertest = require('supertest');
|
||||
const Promise = require('bluebird');
|
||||
const sinon = require('sinon');
|
||||
const moment = require('moment-timezone');
|
||||
const SchedulingDefault = require('../../../../core/server/adapters/scheduling/scheduling-default');
|
||||
|
@ -9,6 +8,7 @@ const models = require('../../../../core/server/models');
|
|||
const config = require('../../../../core/shared/config');
|
||||
const testUtils = require('../../../utils');
|
||||
const localUtils = require('./utils');
|
||||
const {sequence} = require('@tryghost/promise');
|
||||
|
||||
describe('Schedules API', function () {
|
||||
const resources = [];
|
||||
|
@ -86,9 +86,9 @@ describe('Schedules API', function () {
|
|||
}]
|
||||
}));
|
||||
|
||||
const result = await Promise.mapSeries(resources, function (post) {
|
||||
const result = await sequence(resources.map(post => async () => {
|
||||
return models.Post.add(post, {context: {internal: true}});
|
||||
});
|
||||
}));
|
||||
|
||||
result.length.should.eql(5);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue