mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Refactored db dependency out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916 - The refactor was done follow the DI Constructor pattern and prepare module for extraction
This commit is contained in:
parent
b96a8f4f6b
commit
66a6a522e0
2 changed files with 8 additions and 6 deletions
|
@ -6,7 +6,6 @@ const errors = require('@tryghost/errors');
|
||||||
const tpl = require('@tryghost/tpl');
|
const tpl = require('@tryghost/tpl');
|
||||||
|
|
||||||
const urlUtils = require('../../../../shared/url-utils');
|
const urlUtils = require('../../../../shared/url-utils');
|
||||||
const db = require('../../../data/db');
|
|
||||||
const emailTemplate = require('./email-template');
|
const emailTemplate = require('./email-template');
|
||||||
|
|
||||||
const messages = {
|
const messages = {
|
||||||
|
@ -19,18 +18,20 @@ module.exports = class MembersCSVImporter {
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {string} config.storagePath - The path to store CSV's in before importing
|
* @param {string} config.storagePath - The path to store CSV's in before importing
|
||||||
* @param {Object} settingsCache - An instance of the Ghost Settings Cache
|
* @param {Object} settingsCache - An instance of the Ghost Settings Cache
|
||||||
* @param {Object} ghostMailer - An instance of GhostMailer
|
* @param {() => Object} getMembersApi
|
||||||
|
* @param {Object} ghostMailer - An instance of GhostMailer
|
||||||
* @param {(string) => boolean} isSet - Method checking if specific feature is enabled
|
* @param {(string) => boolean} isSet - Method checking if specific feature is enabled
|
||||||
* @param {({name, at, job, data, offloaded}) => void} addJob - Method registering an async job
|
* @param {({name, at, job, data, offloaded}) => void} addJob - Method registering an async job
|
||||||
* @param {() => Object} getMembersApi
|
* @param {Object} knex - An instance of the Ghost Database connection
|
||||||
*/
|
*/
|
||||||
constructor(config, settingsCache, getMembersApi, ghostMailer, isSet, addJob) {
|
constructor(config, settingsCache, getMembersApi, ghostMailer, isSet, addJob, knex) {
|
||||||
this._storagePath = config.storagePath;
|
this._storagePath = config.storagePath;
|
||||||
this._settingsCache = settingsCache;
|
this._settingsCache = settingsCache;
|
||||||
this._getMembersApi = getMembersApi;
|
this._getMembersApi = getMembersApi;
|
||||||
this._ghostMailer = ghostMailer;
|
this._ghostMailer = ghostMailer;
|
||||||
this._isSet = isSet;
|
this._isSet = isSet;
|
||||||
this._addJob = addJob;
|
this._addJob = addJob;
|
||||||
|
this._knex = knex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +129,7 @@ module.exports = class MembersCSVImporter {
|
||||||
const result = await rows.reduce(async (resultPromise, row) => {
|
const result = await rows.reduce(async (resultPromise, row) => {
|
||||||
const resultAccumulator = await resultPromise;
|
const resultAccumulator = await resultPromise;
|
||||||
|
|
||||||
const trx = await db.knex.transaction();
|
const trx = await this._knex.transaction();
|
||||||
const options = {
|
const options = {
|
||||||
transacting: trx
|
transacting: trx
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,7 +134,8 @@ const membersService = {
|
||||||
() => membersApi,
|
() => membersApi,
|
||||||
ghostMailer,
|
ghostMailer,
|
||||||
labsService.isSet,
|
labsService.isSet,
|
||||||
jobsService.addJob
|
jobsService.addJob,
|
||||||
|
db.knex
|
||||||
),
|
),
|
||||||
|
|
||||||
stats: new MembersStats({
|
stats: new MembersStats({
|
||||||
|
|
Loading…
Add table
Reference in a new issue