From 6ec297a694ef2670415b5f4120c1f329dde2165f Mon Sep 17 00:00:00 2001 From: Alexey Kolpakov Date: Wed, 11 Sep 2019 17:19:57 +0300 Subject: [PATCH] impr --- package.json | 2 +- src/models/Offer.ts | 4 ++-- yarn.lock | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 181ad18..7244a44 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dependencies": { "@types/ejs": "^2.6.3", "@types/mongoose": "^5.5.17", - "@types/node": "^12.7.4", + "@types/node": "^12.7.5", "@types/qs": "^6.5.3", "@types/ramda": "^0.26.21", "axios": "^0.19.0", diff --git a/src/models/Offer.ts b/src/models/Offer.ts index 91085e1..6b44cb8 100644 --- a/src/models/Offer.ts +++ b/src/models/Offer.ts @@ -36,11 +36,11 @@ abstract class Offer extends CommonModel { public is_notifications_send?: boolean; } - +const oddAddressPartRegexp = /(Россия|г\.?\s?Москва|Москва),\s*/g; @pre(/^findOneAndUpdate/, function() { const location = path(['_update', 'location'], this); if (location && 'address' in location && location.address) { - location.short_address = location.address.replace(/(Россия|Москва),\s*/g, '').replace(/,\s?,/g, ','); + location.short_address = location.address.replace(oddAddressPartRegexp, '').replace(/,\s?,/g, ','); } }) @index({ source: 1, ext_id: 1 }, { unique: true }) diff --git a/yarn.lock b/yarn.lock index f6f4a1d..30d29c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -46,11 +46,16 @@ "@types/mongodb" "*" "@types/node" "*" -"@types/node@*", "@types/node@^12.0.4", "@types/node@^12.7.4": +"@types/node@*", "@types/node@^12.0.4": version "12.7.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.4.tgz#64db61e0359eb5a8d99b55e05c729f130a678b04" integrity sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ== +"@types/node@^12.7.5": + version "12.7.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f" + integrity sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w== + "@types/node@^8.0.7": version "8.10.53" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.53.tgz#5fa08eef810b08b2c03073e360b54f7bad899db1"