mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Refactored settingsCache parameter
refs https://github.com/TryGhost/Team/issues/916 - The constructor API should have as small of a surface as possible, there's no need to pass around whole settingsCache instance
This commit is contained in:
parent
19c5c0b05a
commit
83c75a3fb4
2 changed files with 5 additions and 5 deletions
|
@ -16,7 +16,7 @@ module.exports = class MembersCSVImporter {
|
||||||
/**
|
/**
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @param {string} options.storagePath - The path to store CSV's in before importing
|
* @param {string} options.storagePath - The path to store CSV's in before importing
|
||||||
* @param {Object} options.settingsCache - An instance of the Ghost Settings Cache
|
* @param {Function} options.getTimezone - function returning currently configured timezone
|
||||||
* @param {() => Object} options.getMembersApi
|
* @param {() => Object} options.getMembersApi
|
||||||
* @param {Object} options.ghostMailer - An instance of GhostMailer
|
* @param {Object} options.ghostMailer - An instance of GhostMailer
|
||||||
* @param {(string) => boolean} options.isSet - Method checking if specific feature is enabled
|
* @param {(string) => boolean} options.isSet - Method checking if specific feature is enabled
|
||||||
|
@ -24,9 +24,9 @@ module.exports = class MembersCSVImporter {
|
||||||
* @param {Object} options.knex - An instance of the Ghost Database connection
|
* @param {Object} options.knex - An instance of the Ghost Database connection
|
||||||
* @param {Function} options.urlFor - function generating urls
|
* @param {Function} options.urlFor - function generating urls
|
||||||
*/
|
*/
|
||||||
constructor({storagePath, settingsCache, getMembersApi, ghostMailer, isSet, addJob, knex, urlFor}) {
|
constructor({storagePath, getTimezone, getMembersApi, ghostMailer, isSet, addJob, knex, urlFor}) {
|
||||||
this._storagePath = storagePath;
|
this._storagePath = storagePath;
|
||||||
this._settingsCache = settingsCache;
|
this._getTimezone = getTimezone;
|
||||||
this._getMembersApi = getMembersApi;
|
this._getMembersApi = getMembersApi;
|
||||||
this._ghostMailer = ghostMailer;
|
this._ghostMailer = ghostMailer;
|
||||||
this._isSet = isSet;
|
this._isSet = isSet;
|
||||||
|
@ -75,7 +75,7 @@ module.exports = class MembersCSVImporter {
|
||||||
async prepare(inputFilePath, headerMapping, defaultLabels) {
|
async prepare(inputFilePath, headerMapping, defaultLabels) {
|
||||||
const batchSize = 1;
|
const batchSize = 1;
|
||||||
|
|
||||||
const siteTimezone = this._settingsCache.get('timezone');
|
const siteTimezone = this._getTimezone();
|
||||||
const currentTime = moment().tz(siteTimezone).format('YYYY-MM-DD HH:mm:ss.SSS');
|
const currentTime = moment().tz(siteTimezone).format('YYYY-MM-DD HH:mm:ss.SSS');
|
||||||
const outputFileName = `Members Import ${currentTime}.csv`;
|
const outputFileName = `Members Import ${currentTime}.csv`;
|
||||||
const outputFilePath = path.join(this._storagePath, '/', outputFileName);
|
const outputFilePath = path.join(this._storagePath, '/', outputFileName);
|
||||||
|
|
|
@ -129,7 +129,7 @@ const membersService = {
|
||||||
|
|
||||||
importer: new MembersCSVImporter({
|
importer: new MembersCSVImporter({
|
||||||
storagePath: config.getContentPath('data'),
|
storagePath: config.getContentPath('data'),
|
||||||
settingsCache,
|
getTimezone: () => settingsCache.get('timezone'),
|
||||||
getMembersApi: () => membersApi,
|
getMembersApi: () => membersApi,
|
||||||
ghostMailer,
|
ghostMailer,
|
||||||
isSet: labsService.isSet,
|
isSet: labsService.isSet,
|
||||||
|
|
Loading…
Add table
Reference in a new issue