Skip to content

Commit

Permalink
delete console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Jan 31, 2024
1 parent cd0be12 commit b62eff9
Show file tree
Hide file tree
Showing 26 changed files with 24 additions and 85 deletions.
1 change: 0 additions & 1 deletion adapters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class Adapter {
adapterName = adapter;
}
else if (adapter instanceof DeliveryAdapter_1.default) {
console.log(">>>");
this.instanceDeliveryAdapter = adapter;
return this.instanceDeliveryAdapter;
}
Expand Down
1 change: 0 additions & 1 deletion adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ export class Adapter {
if (typeof adapter === "string") {
adapterName = adapter;
} else if (adapter instanceof DeliveryAdapter) {
console.log(">>>")
this.instanceDeliveryAdapter = adapter;
return this.instanceDeliveryAdapter;
}
Expand Down
2 changes: 0 additions & 2 deletions adapters/mediafile/default/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }) {
imageMagick(srcPath)
.size((err, dimensions) => {
if (err) {
console.log(err);
return reject(new Error(err));
}
// Определяем, какая сторона меньше
Expand All @@ -214,7 +213,6 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }) {
.out(...customArgs)
.write(dstPath, (err) => {
if (err) {
console.log(err);
reject(new Error(err));
}
else {
Expand Down
2 changes: 0 additions & 2 deletions adapters/mediafile/default/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }: ResizeMediaFile
imageMagick(srcPath)
.size((err, dimensions) => {
if (err) {
console.log(err);
return reject(new Error(err));
}

Expand All @@ -245,7 +244,6 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }: ResizeMediaFile
.out(...customArgs)
.write(dstPath, (err) => {
if (err) {
console.log(err);
reject(new Error(err));
} else {
resolve();
Expand Down
1 change: 0 additions & 1 deletion adapters/otp/default/defaultOTP.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class DefaultOTP extends OneTimePasswordAdapter_1.default {
let mainLoginField = await Settings.get("LOGIN_FIELD") ?? 'phone';
if (NotificationManager.isChannelExist(mainLoginField === "phone" ? "sms" : mainLoginField)) {
try {
console.log(">>>>>>>>>>>> to user");
await NotificationManager.sendMessageToUser("info", `Your code is ${otp.password}`, { phone: { code: "", number: login } });
}
catch (error) {
Expand Down
1 change: 0 additions & 1 deletion adapters/otp/default/defaultOTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class DefaultOTP extends OneTimePasswordAdapter {
let mainLoginField = await Settings.get("LOGIN_FIELD") as string ?? 'phone';
if (NotificationManager.isChannelExist(mainLoginField === "phone" ? "sms" : mainLoginField)){
try {
console.log(">>>>>>>>>>>> to user")
await NotificationManager.sendMessageToUser("info", `Your code is ${otp.password}`,{ phone: { code: "", number:login}});
} catch (error) {
sails.log.error(`SEND OTP ERROR: ${error}`)
Expand Down
1 change: 0 additions & 1 deletion adapters/promotion/default/configuredPromotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ConfiguredPromotion extends AbstractPromotion_1.default {
return false;
}
async action(order) {
// console.log(this.config + " action")
let mass = await this.applyPromotion(order);
return mass;
}
Expand Down
1 change: 0 additions & 1 deletion adapters/promotion/default/configuredPromotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export default class ConfiguredPromotion extends AbstractPromotionHandler {
}

public async action(order: Order): Promise<PromotionState> {
// console.log(this.config + " action")
let mass: PromotionState = await this.applyPromotion(order)
return mass
}
Expand Down
1 change: 0 additions & 1 deletion interfaces/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class Adapter {
adapterName = adapter;
}
else if (adapter instanceof DeliveryAdapter_1.default) {
console.log(">>>");
this.instanceDeliveryAdapter = adapter;
return this.instanceDeliveryAdapter;
}
Expand Down
1 change: 0 additions & 1 deletion interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ export class Adapter {
if (typeof adapter === "string") {
adapterName = adapter;
} else if (adapter instanceof DeliveryAdapter) {
console.log(">>>")
this.instanceDeliveryAdapter = adapter;
return this.instanceDeliveryAdapter;
}
Expand Down
1 change: 0 additions & 1 deletion libs/phoneValidByMask.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function phoneValidByMask(phoneNumber, countryCode, phoneMasks) {
if (maskDigits.length === phoneNumberDigits.length) {
let isValid = true;
for (let i = 0; i < maskDigits.length; i++) {
console.log(phoneNumberDigits[i], maskDigits[i]);
if (isNaN(parseInt(phoneNumberDigits[i]))) {
isValid = false;
break;
Expand Down
1 change: 0 additions & 1 deletion libs/phoneValidByMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function phoneValidByMask(phoneNumber: string, countryCode: string, phone
if (maskDigits.length === phoneNumberDigits.length) {
let isValid: boolean = true;
for (let i = 0; i < maskDigits.length; i++) {
console.log(phoneNumberDigits[i], maskDigits[i]);
if (isNaN(parseInt(phoneNumberDigits[i]))) {
isValid = false;
break;
Expand Down
8 changes: 4 additions & 4 deletions models/Order.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare let attributes: {
/**
* @deprecated will be rename to `Items` in **v2**
*/
dishes: number[] | OrderDish[];
dishes: OrderDish[] | number[];
paymentMethod: any;
/** */
paymentMethodTitle: string;
Expand Down Expand Up @@ -161,7 +161,7 @@ declare let Model: {
beforeCreate(orderInit: Order, cb: (err?: string) => void): void;
afterCreate(order: Order, cb: (err?: string) => void): Promise<void>;
/** Add dish into order */
addDish(criteria: CriteriaQuery<Order>, dish: string | Dish, amount: number, modifiers: OrderModifier[], comment: string, addedBy: "user" | "promotion" | "core" | "custom", replace?: boolean, orderDishId?: number): Promise<void>;
addDish(criteria: CriteriaQuery<Order>, dish: Dish | string, amount: number, modifiers: OrderModifier[], comment: string, addedBy: "user" | "promotion" | "core" | "custom", replace?: boolean, orderDishId?: number): Promise<void>;
removeDish(criteria: CriteriaQuery<Order>, dish: OrderDish, amount: number, stack?: boolean): Promise<void>;
setCount(criteria: CriteriaQuery<Order>, dish: OrderDish, amount: number): Promise<void>;
setComment(criteria: CriteriaQuery<Order>, dish: OrderDish, comment: string): Promise<void>;
Expand Down Expand Up @@ -206,7 +206,7 @@ declare let Model: {
state?: string;
concept?: string;
isMixedConcept?: boolean;
dishes?: number[] | OrderDish[];
dishes?: OrderDish[] | number[];
paymentMethod?: any;
paymentMethodTitle?: string;
paid?: boolean;
Expand Down Expand Up @@ -266,7 +266,7 @@ declare let Model: {
*/
countCart(criteria: CriteriaQuery<Order>, isPromoting?: boolean): Promise<Order>;
doPaid(criteria: CriteriaQuery<Order>, paymentDocument: PaymentDocument): Promise<void>;
applyPromotionCode(criteria: CriteriaQuery<Order>, promotionCodeString: string): Promise<Order>;
applyPromotionCode(criteria: CriteriaQuery<Order>, promotionCodeString: string | null): Promise<Order>;
};
declare global {
const Order: typeof Model & ORMModel<Order, null> & StateFlowModel;
Expand Down
5 changes: 3 additions & 2 deletions models/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,9 @@ let Model = {
try {
let order = await Order.findOne(criteria);
if (order.isPromoting !== isPromoting) {
sails.log.error(`The order status does not match the passed parameters order.isPromoting [${order.isPromoting}], attribute [${isPromoting}], check your promotions`);
let err = `CountCart: The order status does not match the passed parameters order.isPromoting [${order.isPromoting}], attribute [${isPromoting}], check your promotions`;
sails.log.error(err);
throw new Error(err);
}
order.isPromoting = isPromoting;
emitter.emit("core-order-before-count", order);
Expand Down Expand Up @@ -1093,7 +1095,6 @@ let Model = {
dishesCount += orderDish.amount;
uniqueDishes++;
totalWeight = totalWeight.plus(orderDish.totalWeight);
// console.log(totalWeight, "TOTAL WEIGTH IN THE END =====================")
}
catch (e) {
sails.log.error("Order > count > iterate orderDish error", e);
Expand Down
5 changes: 3 additions & 2 deletions models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,9 @@ let Model = {

let order = await Order.findOne(criteria);
if (order.isPromoting !== isPromoting) {
sails.log.error(`The order status does not match the passed parameters order.isPromoting [${order.isPromoting}], attribute [${isPromoting}], check your promotions`)
let err = `CountCart: The order status does not match the passed parameters order.isPromoting [${order.isPromoting}], attribute [${isPromoting}], check your promotions`
sails.log.error(err);
throw new Error(err)
}
order.isPromoting = isPromoting;

Expand Down Expand Up @@ -1327,7 +1329,6 @@ let Model = {
dishesCount += orderDish.amount;
uniqueDishes++;
totalWeight = totalWeight.plus(orderDish.totalWeight);
// console.log(totalWeight, "TOTAL WEIGTH IN THE END =====================")
} catch (e) {
sails.log.error("Order > count > iterate orderDish error", e);
await OrderDish.destroy({ id: orderDish.id });
Expand Down
3 changes: 2 additions & 1 deletion models/Promotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ let Model = {
}
}
catch (error) {
console.log(error);
sails.log.error(error);
throw new Error(error);
}
},
getAllByConcept(concept) {
Expand Down
3 changes: 2 additions & 1 deletion models/Promotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ let Model = {
}

} catch (error) {
console.log(error);
sails.log.error(error);
throw new Error(error)
}
},

Expand Down
1 change: 0 additions & 1 deletion models/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ module.exports = {
};
function toScreamingSnake(str) {
if (!str) {
console.log("STR", str);
return '';
}
// Test123___Test_test -> TEST123_TEST_TEST
Expand Down
1 change: 0 additions & 1 deletion models/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ declare global {

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

Expand Down
2 changes: 1 addition & 1 deletion models/User.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ declare let Model: {
* @param {WaterlineCriteria} criteria
* @returns String
*/
getPhoneString(phone: Phone, target?: "string" | "login" | "print"): Promise<string>;
getPhoneString(phone: Phone, target?: "login" | "print" | "string"): Promise<string>;
/**
* Update user password
*
Expand Down
12 changes: 6 additions & 6 deletions models/UserBonusProgram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ interface UserBonusProgram extends attributes, ORM {
export default UserBonusProgram;
declare let Model: {
beforeCreate(init: UserBonusProgram, cb: (err?: string) => void): void;
registration(user: string | User, adapterOrId: string): Promise<UserBonusProgram>;
delete(user: string | User, adapterOrId: string): Promise<void>;
syncAll(user: string | User): Promise<void>;
registration(user: User | string, adapterOrId: string): Promise<UserBonusProgram>;
delete(user: User | string, adapterOrId: string): Promise<void>;
syncAll(user: User | string): Promise<void>;
/** Full sync all transaction with external system */
sync(user: string | User, bonusProgram: string | BonusProgram, force?: boolean): Promise<void>;
checkEnoughToSpend(user: string | User, bonusProgram: string | BonusProgram, amount: number): Promise<boolean>;
sumCurrentBalance(user: string | User, bonusProgram: string | BonusProgram): Promise<number>;
sync(user: User | string, bonusProgram: BonusProgram | string, force?: boolean): Promise<void>;
checkEnoughToSpend(user: User | string, bonusProgram: BonusProgram | string, amount: number): Promise<boolean>;
sumCurrentBalance(user: User | string, bonusProgram: BonusProgram | string): Promise<number>;
};
declare global {
const UserBonusProgram: typeof Model & ORMModel<UserBonusProgram, "user" | "bonusProgram">;
Expand Down
3 changes: 0 additions & 3 deletions test/integration/adapters/promotion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ describe("Promotion adapter integration test", function () {
await promotionAdapter.addPromotionHandler(promotion10Percent);
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
await Order.addDish({ id: order.id }, dish2, 4, [], "", "user");
// console.log(await OrderDish.find({order: order.id}))
let result = await Order.findOne(order.id);
// console.log(result, result.promotionState[0])
(0, chai_1.expect)(result.discountTotal).to.equal(11.13);
});
it("IsJoint: false configured discount over total discount for specific dish", async () => {
Expand Down Expand Up @@ -166,7 +164,6 @@ describe("Promotion adapter integration test", function () {
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
await Order.addDish({ id: order.id }, dish2, 4, [], "", "user");
let result = await Order.findOne(order.id);
// console.log(result)
(0, chai_1.expect)(result.discountTotal).to.equal(5);
});
// /**
Expand Down
3 changes: 0 additions & 3 deletions test/integration/adapters/promotion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ describe("Promotion adapter integration test", function () {
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
await Order.addDish({ id: order.id }, dish2, 4, [], "", "user");

// console.log(await OrderDish.find({order: order.id}))
let result = await Order.findOne(order.id)
// console.log(result, result.promotionState[0])
expect(result.discountTotal).to.equal(11.13);
});

Expand Down Expand Up @@ -224,7 +222,6 @@ describe("Promotion adapter integration test", function () {
await Order.addDish({ id: order.id }, dish2, 4, [], "", "user");

let result = await Order.findOne(order.id)
// console.log(result)

expect(result.discountTotal).to.equal(5);
})
Expand Down
20 changes: 0 additions & 20 deletions test/unit/discount/discount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe('Discount', function () {
return false;
},
action: async (order) => {
// console.log("ACTION ================awdawdawd")
return await configuredPromotion.applyPromotion(order);
},
isPublic: true,
Expand Down Expand Up @@ -117,7 +116,6 @@ describe('Discount', function () {
await index_1.Adapter.getPromotionAdapter().addPromotionHandler(discountEx);
let discount = await Promotion.find({});
let discountById = await index_1.Adapter.getPromotionAdapter().getPromotionHandlerById(discountEx.id);
// console.log(discount)
(0, chai_1.expect)(discount[0]).to.be.an("object");
(0, chai_1.expect)(discountById).to.be.an("object");
});
Expand Down Expand Up @@ -164,15 +162,12 @@ describe('Discount', function () {
order = await Order.findOne(order.id);
await promotionAdapter.processOrder(order);
let result = await Order.findOne(order.id); //.populate("dishes");
// console.log(result)
// console.log(result, "get discount order")
(0, chai_1.expect)(result.discountTotal).to.equal(11.97);
let dish3 = await Dish.createOrUpdate((0, dish_generator_1.default)({ name: "test disha", price: 10, concept: "a", parentGroup: groupsId[0] }));
let dish4 = await Dish.createOrUpdate((0, dish_generator_1.default)({ name: "test fisha", price: 15, concept: "a", parentGroup: groupsId[0] }));
await Order.addDish({ id: order.id }, dish3, 5, [], "", "user");
await Order.addDish({ id: order.id }, dish4, 4, [], "", "user");
order = await Order.findOne(order.id);
// console.log(order)
await promotionAdapter.processOrder(order);
result = await Order.findOne(order.id);
(0, chai_1.expect)(result.discountTotal).to.equal(11.97);
Expand All @@ -187,13 +182,10 @@ describe('Discount', function () {
await promotionAdapter.addPromotionHandler(discInMemory);
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
await Order.addDish({ id: order.id }, dish2, 4, [], "", "user");
// console.log(discInMemory)
// let result1 = await Dish.findOne(dish1.id)
// DiscountAdapter.applyToOrder(order)
await index_1.Adapter.getPromotionAdapter().clearOfPromotion(order);
await configuredPromotionFromMemory.applyPromotion(order);
let result = await Order.findOne(order.id); //.populate("dishes");
// console.log(result, "get discount order")
(0, chai_1.expect)(result.discountTotal).to.equal(11.13);
});
it("discount test dishes with flat and percentage types of discounts but same concept", async function () {
Expand All @@ -219,7 +211,6 @@ describe('Discount', function () {
order = await Order.findOne(order.id);
await promotionAdapter.processOrder(order);
let result = await Order.findOne(order.id);
// console.log(result, "get discount order")
(0, chai_1.expect)(result.discountTotal).to.equal(60.45);
});
it("discount test dishes with flat and percentage types of discounts but different concept", async function () {
Expand Down Expand Up @@ -247,7 +238,6 @@ describe('Discount', function () {
order = await Order.findOne(order.id);
await promotionAdapter.processOrder(order);
let result = await Order.findOne(order.id); //.populate("dishes");
// console.log(result, "get discount order")
(0, chai_1.expect)(result.discountTotal).to.equal(49.81);
});
it("discount test dishes with 3 dif type of discount", async function () {
Expand Down Expand Up @@ -276,8 +266,6 @@ describe('Discount', function () {
(0, chai_1.expect)(result.discountTotal).to.equal(62.48);
});
it("discount test displayDish", async function () {
// let order = await Order.create({id: "test-display-dish"}).fetch();
// await Order.updateOne({id: order.id}, {concept: "origin",user: "user"});
let dish1 = await Dish.createOrUpdate((0, dish_generator_1.default)({ name: "test dish2", price: 10.1, concept: "Display Dish", parentGroup: groupsId[0] }));
let dish2 = await Dish.createOrUpdate((0, dish_generator_1.default)({ name: "test fish3", price: 15.2, concept: "Display Dish", parentGroup: groupsId[0] }));
discInMemory.configDiscount.dishes.push(dish1.id);
Expand Down Expand Up @@ -321,17 +309,13 @@ describe('Discount', function () {
let dish1 = await Dish.createOrUpdate((0, dish_generator_1.default)({ name: "test dish", price: 10, concept: "clear", parentGroup: groupsId[0] }));
discountEx.configDiscount.dishes.push(dish1.id);
await promotionAdapter.addPromotionHandler(discountEx);
// console.log(promotionAdapter.promotions)
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
// await Adapter.getPromotionAdapter().applyPromotion(order.id, discountEx.configDiscount, discountEx.id)
// before clear
let orderDishes1 = await OrderDish.find({ order: order.id }).populate("dish");
// console.log(orderDishes1)
(0, chai_1.expect)(orderDishes1[0].discountTotal).to.equal(6.65);
//after clear
await index_1.Adapter.getPromotionAdapter().clearOfPromotion(order);
let orderDishes = await OrderDish.find({ order: order.id }).populate("dish");
// console.log(orderDishes)
(0, chai_1.expect)(orderDishes[0].discountTotal).to.equal(0);
});
it("discount test Adapter.getDiscount ", async function () {
Expand All @@ -343,16 +327,12 @@ describe('Discount', function () {
discountEx.configDiscount.dishes.push(dish1.id);
await a.addPromotionHandler(discountEx);
await Order.addDish({ id: order.id }, dish1, 5, [], "", "user");
// await promotionAdapter.addPromotionHandler(discountEx)
// await Adapter.getPromotionAdapter().applyPromotion(order.id, discountEx.configDiscount, discountEx.id)
// before clear
let orderDishes1 = await OrderDish.find({ order: order.id }).populate("dish");
// console.log(orderDishes1)
(0, chai_1.expect)(orderDishes1[0].discountTotal).to.equal(6.65);
//after clear
await index_1.Adapter.getPromotionAdapter().clearOfPromotion(order);
let orderDishes = await OrderDish.find({ order: order.id }).populate("dish");
// console.log(orderDishes)
(0, chai_1.expect)(orderDishes[0].discountTotal).to.equal(0);
});
// if promotion returns
Expand Down
Loading

0 comments on commit b62eff9

Please sign in to comment.