mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03: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
@ -6,7 +6,6 @@ const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const urlUtils = require('../../../../shared/url-utils');
|
||||
const db = require('../../../data/db');
|
||||
const emailTemplate = require('./email-template');
|
||||
|
||||
const messages = {
|
||||
@ -19,18 +18,20 @@ module.exports = class MembersCSVImporter {
|
||||
* @param {Object} config
|
||||
* @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} 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 {({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._settingsCache = settingsCache;
|
||||
this._getMembersApi = getMembersApi;
|
||||
this._ghostMailer = ghostMailer;
|
||||
this._isSet = isSet;
|
||||
this._addJob = addJob;
|
||||
this._knex = knex;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +129,7 @@ module.exports = class MembersCSVImporter {
|
||||
const result = await rows.reduce(async (resultPromise, row) => {
|
||||
const resultAccumulator = await resultPromise;
|
||||
|
||||
const trx = await db.knex.transaction();
|
||||
const trx = await this._knex.transaction();
|
||||
const options = {
|
||||
transacting: trx
|
||||
};
|
||||
|
@ -134,7 +134,8 @@ const membersService = {
|
||||
() => membersApi,
|
||||
ghostMailer,
|
||||
labsService.isSet,
|
||||
jobsService.addJob
|
||||
jobsService.addJob,
|
||||
db.knex
|
||||
),
|
||||
|
||||
stats: new MembersStats({
|
||||
|
Loading…
Reference in New Issue
Block a user