u
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import * as mssqlQueries from '../../providers/mssql/queries/optionslist.js';
|
||||
import * as sqliteQueries from '../../providers/sqlite3/queries/optionslist.js';
|
||||
import { INSERT as MSSQL_INSERT_HISTORY } from '../../providers/mssql/queries/articlehistory.js';
|
||||
import { INSERT as SQLITE_INSERT_HISTORY } from '../../providers/sqlite3/queries/articlehistory.js';
|
||||
import resolveArticleBySku from '../article/resolveArticleBySku.js';
|
||||
import getOptionsByArticleSku from './getOptionsByArticleSku.js';
|
||||
import {
|
||||
recordOptionsListChangeHistory,
|
||||
recordArticleHistory,
|
||||
} from '../articlehistory/record.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
async function hasOptionslistCycle(runner, rootArticleId, candidateOptionId) {
|
||||
@@ -44,7 +46,6 @@ export default function setOptionsByArticleSku(provider) {
|
||||
const getOptions = getOptionsByArticleSku(provider);
|
||||
const isSqlite = provider?.dialect === 'sqlite3';
|
||||
const queries = isSqlite ? sqliteQueries : mssqlQueries;
|
||||
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
|
||||
|
||||
/**
|
||||
* Sets or clears the options list for an article.
|
||||
@@ -100,10 +101,11 @@ export default function setOptionsByArticleSku(provider) {
|
||||
});
|
||||
|
||||
if (oldOptNames.length) {
|
||||
await runner.query(insertHistorySql, {
|
||||
await recordArticleHistory(runner, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
text: `Optionsliste geleert (war: [${oldOptNames.join(', ')}])`,
|
||||
type: 'optionslist_cleared',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -228,11 +230,10 @@ export default function setOptionsByArticleSku(provider) {
|
||||
const result = await getOptions(googleAuthId, sku, runner);
|
||||
|
||||
// Write history for options list change
|
||||
const newNames = result.map((r) => r.name || r.sku);
|
||||
await runner.query(insertHistorySql, {
|
||||
await recordOptionsListChangeHistory(runner, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
text: `Optionsliste gesetzt: [${newNames.join(', ')}]`,
|
||||
options: result,
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user