Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Jul 20, 2023
1 parent e4d4a89 commit 7a4de34
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 52 deletions.
4 changes: 2 additions & 2 deletions adapters/rms/RMSAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RMSAdapter {
// Get ids of all current RMS groups
const rmsGroupIds = currentRMSGroupsFlatTree.map(group => group.rmsId);
// Set all groups not in the list to inactive
await Group.update({ where: { rmsId: { not: rmsGroupIds } } }, { isDeleted: true }).fetch();
await Group.update({ where: { rmsId: { "!=": rmsGroupIds } } }, { isDeleted: true }).fetch();
for (const group of currentRMSGroupsFlatTree) {
emitter.emit("rms-sync:before-each-group-item", group);
// Update or create group
Expand All @@ -86,7 +86,7 @@ class RMSAdapter {
const inactiveGroups = await Group.find({ isDeleted: true });
const inactiveGroupIds = inactiveGroups.map(group => group.id);
// Delete all dishes in inactive groups or not in the updated list
await Dish.update({ where: { or: [{ parentGroup: { in: inactiveGroupIds } }, { rmsId: { not: allProductIds } }, { parentGroup: null }] } }, { isDeleted: true });
await Dish.update({ where: { or: [{ parentGroup: { in: inactiveGroupIds } }, { rmsId: { "!=": allProductIds } }, { parentGroup: null }] } }, { isDeleted: true });
}
this.syncProductsExecuted = false;
return;
Expand Down
4 changes: 2 additions & 2 deletions adapters/rms/RMSAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default abstract class RMSAdapter {
const rmsGroupIds = currentRMSGroupsFlatTree.map(group => group.rmsId);

// Set all groups not in the list to inactive
await Group.update({ where:{ rmsId: { not: rmsGroupIds }}},{ isDeleted: true }).fetch();
await Group.update({ where:{ rmsId: { "!=": rmsGroupIds }}},{ isDeleted: true }).fetch();

for (const group of currentRMSGroupsFlatTree) {
emitter.emit("rms-sync:before-each-group-item", group);
Expand Down Expand Up @@ -132,7 +132,7 @@ export default abstract class RMSAdapter {
const inactiveGroupIds = inactiveGroups.map(group => group.id);

// Delete all dishes in inactive groups or not in the updated list
await Dish.update({ where:{ or: [ { parentGroup: { in: inactiveGroupIds }}, { rmsId: { not: allProductIds }}, {parentGroup: null} ]}}, { isDeleted: true });
await Dish.update({ where:{ or: [ { parentGroup: { in: inactiveGroupIds }}, { rmsId: { "!=": allProductIds }}, {parentGroup: null} ]}}, { isDeleted: true });
}
this.syncProductsExecuted = false
return
Expand Down
17 changes: 8 additions & 9 deletions hook/afterHook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../adapters/index");
/**
* Initial RMS and set timezone if it given
*/
Expand All @@ -10,19 +9,19 @@ async function default_1() {
* rmsAdapter
*/
const rmsAdapterName = await Settings.use("rmsAdapter", "restocore");
const rmsAdapterConfig = await Settings.use(rmsAdapterName, "restocore");
const rmsAdapterConfig = await Settings.use("rmsAdapterName", "restocore");
const imagesConfig = await Settings.use("images", "restocore");
const timeSyncMenu = await Settings.use("timeSyncMenu", "restocore");
const timeSyncBalance = await Settings.use("timeSyncBalance", "restocore");
const timeSyncStreets = await Settings.use("timeSyncStreets", "restocore");
const timeSyncPayments = await Settings.use("timeSyncPayments", "restocore");
/**
* run instance RMSadapter
*/
if (rmsAdapterName) {
const rmsAdapter = await index_1.RMS.getAdapter(rmsAdapterName);
rmsAdapter.getInstance(rmsAdapterConfig, imagesConfig, timeSyncMenu, timeSyncBalance, timeSyncStreets);
}
// /**
// * run instance RMSadapter
// */
// if (rmsAdapterName) {
// const rmsAdapter = await RMS.getAdapter(rmsAdapterName);
// rmsAdapter.getInstance(rmsAdapterConfig, imagesConfig, timeSyncMenu, timeSyncBalance, timeSyncStreets);
// }
/**
* TIMEZONE
*/
Expand Down
24 changes: 12 additions & 12 deletions hook/afterHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export default async function () {
* rmsAdapter
*/
const rmsAdapterName = await Settings.use("rmsAdapter", "restocore") as string;
const rmsAdapterConfig = await Settings.use(rmsAdapterName, "restocore");
const imagesConfig = await Settings.use("images","restocore");
const timeSyncMenu = await Settings.use("timeSyncMenu","restocore");
const timeSyncBalance = await Settings.use("timeSyncBalance","restocore");
const timeSyncStreets = await Settings.use("timeSyncStreets","restocore");
const rmsAdapterConfig = await Settings.use("rmsAdapterName", "restocore") as any;
const imagesConfig = await Settings.use("images","restocore") as any;
const timeSyncMenu = await Settings.use("timeSyncMenu","restocore") as number;
const timeSyncBalance = await Settings.use("timeSyncBalance","restocore") as number;
const timeSyncStreets = await Settings.use("timeSyncStreets","restocore") as number;
const timeSyncPayments = await Settings.use("timeSyncPayments","restocore") as number;

/**
* run instance RMSadapter
*/
if (rmsAdapterName) {
const rmsAdapter = await RMS.getAdapter(rmsAdapterName);
rmsAdapter.getInstance(rmsAdapterConfig, imagesConfig, timeSyncMenu, timeSyncBalance, timeSyncStreets);
}
// /**
// * run instance RMSadapter
// */
// if (rmsAdapterName) {
// const rmsAdapter = await RMS.getAdapter(rmsAdapterName);
// rmsAdapter.getInstance(rmsAdapterConfig, imagesConfig, timeSyncMenu, timeSyncBalance, timeSyncStreets);
// }

/**
* TIMEZONE
Expand Down
6 changes: 4 additions & 2 deletions interfaces/Modifier.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import Dish from "../models/Dish";
interface BaseModifier {
modifierId: string;
amount?: number;
dish?: Dish;
dish?: Dish | string;
maxAmount?: number;
minAmount?: number;
defaultAmount?: number;
freeAmount?: number;
required: boolean | null;
freeOfChargeAmount?: number | null;
}
export interface OrderModifier {
id: string;
Expand All @@ -21,7 +23,7 @@ export interface Modifier extends BaseModifier {
export interface GroupModifier extends BaseModifier {
id?: string;
childModifiers: Modifier[];
group?: Group | any;
group?: Group | string;
groupId?: string;
isSingleModifierGroupWrapper?: boolean;
}
Expand Down
9 changes: 7 additions & 2 deletions interfaces/Modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import Dish from "../models/Dish";
interface BaseModifier {
modifierId: string;
amount?: number;
dish?: Dish;
dish?: Dish | string;
maxAmount?: number;
minAmount?: number;
defaultAmount?: number;
freeAmount?: number;
required: boolean | null;
freeOfChargeAmount?: number | null;
}

export interface OrderModifier {
Expand All @@ -25,7 +27,10 @@ export interface Modifier extends BaseModifier {
export interface GroupModifier extends BaseModifier {
id?: string; // id не обязательный для поддержки вирутальных групп
childModifiers: Modifier[];
group?: Group | any;
group?: Group | string;
groupId?: string;
isSingleModifierGroupWrapper?: boolean;
}



1 change: 0 additions & 1 deletion models/Dish.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ declare let attributes: {
/** */
productCategoryId: string;
/** Type */
type: string;
/** Weight */
weight: number;
/** Sorting order */
Expand Down
42 changes: 33 additions & 9 deletions models/Dish.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,40 @@ let attributes = {
/** The amount of carbohydrates per (100g)*/
carbohydrateAmount: "number",
/** The amount of carbohydrates in the dish */
carbohydrateFullAmount: "number",
carbohydrateFullAmount: {
type: "number",
allowNull: true
},
/** Energy value (100 g) */
energyAmount: "number",
energyAmount: {
type: "number",
allowNull: true
},
/** Energy value */
energyFullAmount: "number",
energyFullAmount: {
type: "number",
allowNull: true
},
/** The amount of fat (100 g) */
fatAmount: "number",
fatAmount: {
type: "number",
allowNull: true
},
/** The amount of fat in the dish */
fatFullAmount: "number",
fatFullAmount: {
type: "number",
allowNull: true
},
/** The number of proteins (100g) */
fiberAmount: "number",
fiberAmount: {
type: "number",
allowNull: true
},
/** The amount of proteins in the dish */
fiberFullAmount: "number",
fiberFullAmount: {
type: "number",
allowNull: true
},
/** The group identifier in which the dish is located */
groupId: {
type: "string",
Expand All @@ -93,9 +114,12 @@ let attributes = {
allowNull: true,
},
/** Type */
type: "string",
// type: "string", //TODO: ???
/** Weight */
weight: "number",
weight: {
type: "number",
allowNull: true
},
/** Sorting order */
sortOrder: "number",
/** The dish is removed */
Expand Down
42 changes: 33 additions & 9 deletions models/Dish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,46 @@ let attributes = {
carbohydrateAmount: "number" as unknown as number,

/** The amount of carbohydrates in the dish */
carbohydrateFullAmount: "number" as unknown as number,
carbohydrateFullAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** Energy value (100 g) */
energyAmount: "number" as unknown as number,
energyAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** Energy value */
energyFullAmount: "number" as unknown as number,
energyFullAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** The amount of fat (100 g) */
fatAmount: "number" as unknown as number,
fatAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** The amount of fat in the dish */
fatFullAmount: "number" as unknown as number,
fatFullAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** The number of proteins (100g) */
fiberAmount: "number" as unknown as number,
fiberAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** The amount of proteins in the dish */
fiberFullAmount: "number" as unknown as number,
fiberFullAmount: {
type: "number",
allowNull: true
} as unknown as number,

/** The group identifier in which the dish is located */
groupId: {
Expand All @@ -125,10 +146,13 @@ let attributes = {
} as unknown as string,

/** Type */
type: "string", //TODO: ???
// type: "string", //TODO: ???

/** Weight */
weight: "number" as unknown as number,
weight: {
type: "number",
allowNull: true
} as unknown as number,

/** Sorting order */
sortOrder: "number" as unknown as number,
Expand Down
2 changes: 1 addition & 1 deletion models/Group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare let attributes: {
sortOrder: number;
dishes: Dish[];
parentGroup: any;
childGroups: Group[] | string[];
childGroups: string[] | Group[];
/** Icon */
icon: {
type: string;
Expand Down
6 changes: 5 additions & 1 deletion models/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let Model = {
return value;
}
}
sails.log.warn(`Settings: ( ${key} ) not found`);
sails.log.silly(`Settings: ( ${key} ) not found`);
return undefined;
},
async get(key) {
Expand Down Expand Up @@ -159,6 +159,10 @@ module.exports = {
...Model,
};
function toScreamingSnake(str) {
if (!str) {
console.log("STR", str);
return '';
}
// Test123___Test_test -> TEST123_TEST_TEST
return str.replace(/\.?([A-Z]+)/g, function (x, y) { return "_" + y.toLowerCase(); }).replace(/^_/, "").replace(/_{1,}/g, "_").toUpperCase();
}
10 changes: 8 additions & 2 deletions models/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let Model = {
return value;
}
}
sails.log.warn(`Settings: ( ${key} ) not found`);
sails.log.silly(`Settings: ( ${key} ) not found`);

return undefined;
},
Expand Down Expand Up @@ -197,6 +197,12 @@ declare global {


function toScreamingSnake(str: string): string {
if (!str) {
console.log("STR", str)
return '';
}

// Test123___Test_test -> TEST123_TEST_TEST
return str.replace(/\.?([A-Z]+)/g, function (x,y){return "_" + y.toLowerCase()}).replace(/^_/, "").replace(/_{1,}/g,"_").toUpperCase();
}
}

0 comments on commit 7a4de34

Please sign in to comment.