Compare commits
32 Commits
edit-bug-f
...
crawler-se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aa91fb4e2 | ||
|
|
2cf6f6f1ff | ||
|
|
6eba5c2a97 | ||
|
|
2f474619ca | ||
|
|
80ff9bcb6b | ||
|
|
3c59292f23 | ||
|
|
1bcc5e8e5d | ||
|
|
c8ee848f0e | ||
|
|
0f630e9ea4 | ||
|
|
9a8a27d1d9 | ||
|
|
b17b6862ba | ||
|
|
6aaaea1612 | ||
|
|
fdd0124924 | ||
|
|
c15f45e8f4 | ||
|
|
371eac900e | ||
|
|
5d6e7f3938 | ||
|
|
efda7fdccd | ||
|
|
8bb0908c45 | ||
|
|
5c75d690b0 | ||
|
|
f0e8a72756 | ||
|
|
62bf3380cd | ||
|
|
caa1871939 | ||
|
|
506ac67956 | ||
|
|
8f9e3ae46a | ||
|
|
d6e999fcf1 | ||
|
|
08a94ca4f8 | ||
|
|
a0f2b044b2 | ||
|
|
7db74acad7 | ||
|
|
56865b4670 | ||
|
|
1a8ac3fba4 | ||
|
|
de3c76315e | ||
|
|
e969a8dc8b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
.env
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
const { currentRERequest } = require('../helpers/url');
|
const { currentRERequest } = require('../helpers/url');
|
||||||
const { gardenSizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
const { getRealEstateTypeEnum } = require('../helpers/enums');
|
||||||
|
|
||||||
const getGardenSize = (req,res) => {
|
const getGardenSize = (req,res) => {
|
||||||
res.render('gardenSize', { gardenSizes });
|
|
||||||
|
const unit = " m2"
|
||||||
|
const rangeFrom = {
|
||||||
|
min : 10,
|
||||||
|
max : 3000,
|
||||||
|
value : 0,
|
||||||
|
step : 10
|
||||||
|
}
|
||||||
|
|
||||||
|
const rangeTo = {
|
||||||
|
min : 10,
|
||||||
|
max : 3000,
|
||||||
|
value : 100,
|
||||||
|
step : 10
|
||||||
|
}
|
||||||
|
|
||||||
|
res.render('gardenSize', { rangeFrom, rangeTo, unit });
|
||||||
};
|
};
|
||||||
|
|
||||||
const postGardenSize = async (req, res) => {
|
const postGardenSize = async (req, res) => {
|
||||||
@@ -13,7 +29,8 @@ const postGardenSize = async (req, res) => {
|
|||||||
|
|
||||||
const realEstateType = getRealEstateTypeEnum(request.realEstateType);
|
const realEstateType = getRealEstateTypeEnum(request.realEstateType);
|
||||||
if (realEstateType && realEstateType.hasGardenSize) {
|
if (realEstateType && realEstateType.hasGardenSize) {
|
||||||
request.gardenSize = req.body.gardensize;
|
request.gardenSizeMin = req.body.from;
|
||||||
|
request.gardenSizeMax = req.body.to;
|
||||||
await request.save();
|
await request.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
const { currentRERequest } = require('../helpers/url');
|
const { currentRERequest } = require('../helpers/url');
|
||||||
const { prices } = require('../helpers/enums');
|
|
||||||
|
|
||||||
const getPrice = (req,res) => {
|
const getPrice = (req,res) => {
|
||||||
res.render('price', { prices });
|
|
||||||
|
const unit = " KM"
|
||||||
|
const rangeFrom = {
|
||||||
|
min : 1000,
|
||||||
|
max : 250000,
|
||||||
|
value : 0,
|
||||||
|
step : 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
const rangeTo = {
|
||||||
|
min : 1000,
|
||||||
|
max : 250000,
|
||||||
|
value : 50000,
|
||||||
|
step : 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
res.render('price', {rangeFrom, rangeTo, unit });
|
||||||
};
|
};
|
||||||
|
|
||||||
const postPrice = async (req, res) => {
|
const postPrice = async (req, res) => {
|
||||||
@@ -11,7 +27,8 @@ const postPrice = async (req, res) => {
|
|||||||
const nextStepPage = req.query.nextStep || 'pregled';
|
const nextStepPage = req.query.nextStep || 'pregled';
|
||||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||||
|
|
||||||
request.price = req.body.price;
|
request.priceMin = req.body.from;
|
||||||
|
request.priceMax = req.body.to;
|
||||||
await request.save();
|
await request.save();
|
||||||
|
|
||||||
res.redirect(nextStepUrl);
|
res.redirect(nextStepUrl);
|
||||||
|
|||||||
@@ -10,7 +10,16 @@ const getQueryReview = async (req,res) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { realEstateType, region, municipality, size, gardenSize, price } = request.dataValues;
|
const {
|
||||||
|
realEstateType,
|
||||||
|
region,
|
||||||
|
municipality,
|
||||||
|
sizeMin,
|
||||||
|
sizeMax,
|
||||||
|
gardenSizeMin,
|
||||||
|
gardenSizeMax,
|
||||||
|
priceMin,
|
||||||
|
priceMax } = request.dataValues;
|
||||||
|
|
||||||
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
||||||
const enableGardenSizeEdit = realEstateTypeObject ? realEstateTypeObject.hasGardenSize : false;
|
const enableGardenSizeEdit = realEstateTypeObject ? realEstateTypeObject.hasGardenSize : false;
|
||||||
@@ -18,9 +27,9 @@ const getQueryReview = async (req,res) => {
|
|||||||
const realEstateTypeTitle = realEstateType ? getEnumTypeTitle(realEstateTypes, realEstateType) : null;
|
const realEstateTypeTitle = realEstateType ? getEnumTypeTitle(realEstateTypes, realEstateType) : null;
|
||||||
const regionName = region ? getRegionName(region) : null;
|
const regionName = region ? getRegionName(region) : null;
|
||||||
const municipalityName = (region && municipality) ? getMunicipalityName(region, municipality) : null;
|
const municipalityName = (region && municipality) ? getMunicipalityName(region, municipality) : null;
|
||||||
const sizeTitle = size ? getEnumTypeTitle(sizes, size) : null;
|
const sizeTitle = sizeMin ? sizeMin + "-" + sizeMax + " m2" : null;
|
||||||
const gardenSizeTitle = gardenSize ? getEnumTypeTitle(gardenSizes, gardenSize) : null;
|
const gardenSizeTitle = gardenSizeMin ? gardenSizeMin + "-" + gardenSizeMax + " m2" : null;
|
||||||
const priceTitle = price ? getEnumTypeTitle(prices, price) : null;
|
const priceTitle = priceMin ? priceMin + "-" + priceMax + " KM" : null;
|
||||||
|
|
||||||
const uniqueId = request.dataValues.uniqueId ? request.dataValues.uniqueId : '';
|
const uniqueId = request.dataValues.uniqueId ? request.dataValues.uniqueId : '';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const { currentRERequest } = require('../helpers/url');
|
const { currentRERequest } = require('../helpers/url');
|
||||||
const { isValidEmail } = require('../helpers/email');
|
const { isValidEmail } = require('../helpers/email');
|
||||||
|
const { sendTemplatedEmail} = require('../helpers/awsEmail');
|
||||||
|
|
||||||
const getQuerySubmit = async (req,res) => {
|
const getQuerySubmit = async (req, res) => {
|
||||||
const nextStep = req.query.nextStep;
|
const nextStep = req.query.nextStep;
|
||||||
const error = req.query.error;
|
const error = req.query.error;
|
||||||
|
|
||||||
@@ -16,14 +17,32 @@ const postQuerySubmit = async (req, res) => {
|
|||||||
const nextStep = req.query.nextStep || '/ponovo';
|
const nextStep = req.query.nextStep || '/ponovo';
|
||||||
|
|
||||||
const emailInput = req.body.email;
|
const emailInput = req.body.email;
|
||||||
|
const emailConfirmInput = req.body.confirm;
|
||||||
|
let error = "Greška ! Unesite validan email";
|
||||||
|
|
||||||
if (isValidEmail(emailInput)){
|
if (!isValidEmail(emailInput) || !isValidEmail(emailConfirmInput)) {
|
||||||
request.email = req.body.email;
|
|
||||||
await request.save();
|
error = "Greška ! Unesite validan email";
|
||||||
res.redirect(nextStep);
|
res.render('querySubmit', {
|
||||||
} else {
|
error
|
||||||
res.redirect('?error=1');
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (emailInput !== emailConfirmInput) {
|
||||||
|
|
||||||
|
error = "Greška ! Unešeni emailovi nisu isti";
|
||||||
|
res.render('querySubmit', {
|
||||||
|
error
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.email = req.body.email;
|
||||||
|
request.subscribed = true;
|
||||||
|
await request.save();
|
||||||
|
sendTemplatedEmail(req.body.email, request);
|
||||||
|
res.redirect(nextStep);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -2,7 +2,23 @@ const { currentRERequest } = require('../helpers/url');
|
|||||||
const { sizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
const { sizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||||
|
|
||||||
const getSize = (req,res) => {
|
const getSize = (req,res) => {
|
||||||
res.render('size', { sizes });
|
|
||||||
|
const unit = " m2"
|
||||||
|
const rangeFrom = {
|
||||||
|
min : 10,
|
||||||
|
max : 250,
|
||||||
|
value : 0,
|
||||||
|
step : 10
|
||||||
|
}
|
||||||
|
|
||||||
|
const rangeTo = {
|
||||||
|
min : 10,
|
||||||
|
max : 250,
|
||||||
|
value : 50,
|
||||||
|
step : 10
|
||||||
|
}
|
||||||
|
|
||||||
|
res.render('size', { rangeFrom, rangeTo, unit });
|
||||||
};
|
};
|
||||||
|
|
||||||
const postSize = async (req, res) => {
|
const postSize = async (req, res) => {
|
||||||
@@ -13,8 +29,8 @@ const postSize = async (req, res) => {
|
|||||||
const nextStep = realEstateType && realEstateType.hasGardenSize ? 'okucnica' : 'cijena';
|
const nextStep = realEstateType && realEstateType.hasGardenSize ? 'okucnica' : 'cijena';
|
||||||
const nextStepPage = req.query.nextStep || nextStep;
|
const nextStepPage = req.query.nextStep || nextStep;
|
||||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||||
|
request.sizeMin = req.body.from;
|
||||||
request.size = req.body.size;
|
request.sizeMax = req.body.to;
|
||||||
await request.save();
|
await request.save();
|
||||||
|
|
||||||
res.redirect(nextStepUrl);
|
res.redirect(nextStepUrl);
|
||||||
|
|||||||
15
app/controllers/unsubscribe.js
Normal file
15
app/controllers/unsubscribe.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
const { currentRERequest } = require('../helpers/url');
|
||||||
|
|
||||||
|
const getUnsubscribe = async (req, res) => {
|
||||||
|
const request = await currentRERequest(req);
|
||||||
|
request.subscribed = false;
|
||||||
|
await request.save();
|
||||||
|
|
||||||
|
res.render('unsubscribe', { nextStep: '/vrstanekretnine' });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getUnsubscribe
|
||||||
|
};
|
||||||
96
app/helpers/awsEmail.js
Normal file
96
app/helpers/awsEmail.js
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
const dotenv = require('dotenv');
|
||||||
|
dotenv.config();
|
||||||
|
const { getRealEstateTypeEnum } = require('./enums');
|
||||||
|
const { getRegionName, getMunicipalityName } = require('./codes');
|
||||||
|
const AWS = require('aws-sdk');
|
||||||
|
AWS.config.update({
|
||||||
|
region: process.env.AMAZON_REGION,
|
||||||
|
credentials:
|
||||||
|
{
|
||||||
|
accessKeyId: process.env.AMAZON_ACCES_KEY_ID,
|
||||||
|
secretAccessKey: process.env.AMAZON_SECRET_ACCESS_KEY
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const sendTemplatedEmail = async (email, request) => {
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
Destination: { /* required */
|
||||||
|
CcAddresses: [
|
||||||
|
],
|
||||||
|
ToAddresses: [
|
||||||
|
email
|
||||||
|
]
|
||||||
|
},
|
||||||
|
Message: { /* required */
|
||||||
|
Body: { /* required */
|
||||||
|
Html: {
|
||||||
|
Charset: "UTF-8",
|
||||||
|
Data: getEmailHTML(request)
|
||||||
|
},
|
||||||
|
Text: {
|
||||||
|
Charset: "UTF-8",
|
||||||
|
Data: getEmaiTextVersion(request)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Subject: {
|
||||||
|
Charset: 'UTF-8',
|
||||||
|
Data: `Javimi Potvrda: ${request.realEstateType} ${getRegionName(request.region)}, ${getMunicipalityName(request.region, request.municipality)}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Source: process.env.SOURCE_EMAIL, /* required */
|
||||||
|
ReplyToAddresses: [
|
||||||
|
process.env.SOURCE_EMAIL,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendEmailPromise = new AWS.SES({ apiVersion: '2010-12-01' }).sendEmail(params).promise();
|
||||||
|
await sendEmailPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getEmailHTML = (realestateRequest) => {
|
||||||
|
const realEstateType = getRealEstateTypeEnum(realestateRequest.realEstateType);
|
||||||
|
const gardenSize = realEstateType.hasGardenSize ? `<div><strong>Kvadratura okućnice: Od ${realestateRequest.gardenSizeMin} do ${realestateRequest.gardenSizeMax} m2 </strong></div>` : ``
|
||||||
|
|
||||||
|
return `<h1> Zdravo,
|
||||||
|
Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima. </h1>
|
||||||
|
<h2> Ovo je tražena nekretnina: </h2>
|
||||||
|
<div>
|
||||||
|
<div> <strong>Tip nekretnine: ${realEstateType.title} </strong></div>
|
||||||
|
<div><strong>Područje: ${getRegionName(realestateRequest.region)} </strong></div>
|
||||||
|
<div><strong>Mjesto: ${getMunicipalityName(realestateRequest.region, realestateRequest.municipality)} </strong></div>
|
||||||
|
<div><strong>Kvadratura nekretnine: Od ${realestateRequest.sizeMin} do ${realestateRequest.sizeMax} m2 </strong></div>
|
||||||
|
${gardenSize}
|
||||||
|
<div><strong>Cijena: ${realestateRequest.priceMin} do ${realestateRequest.priceMax} KM </strong></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div><strong> Ako želis prestati dobijati obavještenja za ovu pretragu klikni ${process.env.APP_URL}/odjava/${realestateRequest.uniqueId} </strong></div>
|
||||||
|
<div><strong>Ako želiš promijeniti uslove pretrage klikni ${process.env.APP_URL}/pregled/${realestateRequest.uniqueId} </strong></div>
|
||||||
|
<h4> Tvoj,
|
||||||
|
Javimi tim.
|
||||||
|
</h4>`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const getEmaiTextVersion = (realestateRequest) => {
|
||||||
|
const realEstateType = getRealEstateTypeEnum(realestateRequest.realEstateType);
|
||||||
|
const gardenSize = realEstateType.hasGardenSize ? "Kvadratura okućnice od " + realestateRequest.gardenSizeMin + " do " + realestateRequest.gardenSizeMax : ""
|
||||||
|
|
||||||
|
const text = "Zdravo, \n Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima \n Ovo je tražena nekretnina: \n , Tip nekretnine: "
|
||||||
|
+ realestateRequest.realEstateType + "\n Područje" + getRegionName(realestateRequest.region) + "\n Mjesto " + getMunicipalityName(realestateRequest.region, realestateRequest.municipality)
|
||||||
|
+ "\n Kvadratura nekretnine Od " + realestateRequest.sizeMin + " do " + realestateRequest.sizeMaX +
|
||||||
|
+ gardenSize
|
||||||
|
"\n Cijena od " + realestateRequest.priceMin + " do " + realestateRequest.priceMax +
|
||||||
|
"\n Ako želis prestati dobijati obavještenja za ovu pretragu klikni" + process.env.APP_URL + "/odjava/" + realestateRequest.uniqueId +
|
||||||
|
"\n Ako želiš promijeniti uslove pretrage klikni " + process.env.APP_URL + "/odpregled/" + realestateRequest.uniqueId +
|
||||||
|
"\n Tvoj,\n Javimi tim"
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
sendTemplatedEmail
|
||||||
|
};
|
||||||
1042
app/helpers/codes.js
1042
app/helpers/codes.js
File diff suppressed because it is too large
Load Diff
234
app/helpers/crawlers/olxClawler.js
Normal file
234
app/helpers/crawlers/olxClawler.js
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
const fetch = require('node-fetch');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { allRERequest, findPointInsideBoundingBox } = require('../db/dbHelper');
|
||||||
|
const { getRealEstateTypeEnum } = require('../enums');
|
||||||
|
const { getRegion, getMunicipality } = require('../codes')
|
||||||
|
const Promise = require("bluebird");
|
||||||
|
|
||||||
|
module.exports = class OlxCrawler {
|
||||||
|
//TODO figure best way to handle paging
|
||||||
|
constructor(fromPage = 0, toPage = 10, maxResults = 1000) {
|
||||||
|
this.fromPage = fromPage;
|
||||||
|
this.toPage = toPage;
|
||||||
|
this.maxResults = maxResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
async indexSingle(url, email) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(url);
|
||||||
|
const body = await res.text();
|
||||||
|
const $ = cheerio.load(body);
|
||||||
|
|
||||||
|
//TODO figure out what to do with username
|
||||||
|
const username = $('#lg > div.desno2.profil > div:nth-child(2) > div.vrsta1.vrsta_desno > a > div.username > span').text();
|
||||||
|
|
||||||
|
// if (IGNORED_USERNAMES.includes((username || '').toLowerCase())) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//TODO remove properties that are not needed, and add some if they are missing
|
||||||
|
const title = $('#naslovartikla').text();
|
||||||
|
const realEstateType = $('#artikal_glavni_div > div.artikal_lijevo > div:nth-child(3) > div > span:nth-child(3) > a > span').text();
|
||||||
|
|
||||||
|
const price = $('#pc > p:nth-child(2)').text();
|
||||||
|
const size = $('#dodatnapolja1 > div:nth-child(1) > div.df2').text();
|
||||||
|
const rooms = $('#dodatnapolja1 > div:nth-child(2) > div.df2').text();
|
||||||
|
const address = $('#dodatnapolja1 > div:nth-child(5) > div.df2').text();
|
||||||
|
const gardenSize = $('#dodatnapolja1 > div:nth-child(6) > div.df2').text();
|
||||||
|
const location = $('#artikal_glavni_div > div.artikal_lijevo > div.op.pop.mobile-lokacija').attr('data-content');
|
||||||
|
|
||||||
|
const adType = $('#artikal_glavni_div > div.artikal_lijevo > div:nth-child(15) > div:nth-child(2) > div.df2').text();
|
||||||
|
const time = $('time').attr('datetime');
|
||||||
|
const olxId = $('#artikal_glavni_div > div.artikal_lijevo > div:nth-child(15) > div:nth-child(4) > div.df2').text();
|
||||||
|
|
||||||
|
const descriptions = $('.artikal_detaljniopis_tekst');
|
||||||
|
// const floor = $('#dodatnapolja1').find(':contains(Sprat)').last().nextAll().text();
|
||||||
|
const latLngRe = /LatLng\(([0-9]+\.[0-9]+)\,\s+([0-9]+\.[0-9]+)\)/g;
|
||||||
|
const imgRe = /href":("[^"]*")/g;
|
||||||
|
const matches = latLngRe.exec(body);
|
||||||
|
let lng = '',
|
||||||
|
lat = '';
|
||||||
|
|
||||||
|
|
||||||
|
const parseRooms = (rooms) => parseInt([...rooms].filter(c => !isNaN(c)).filter(c => c.trim()).join())
|
||||||
|
const parsePrice = (price) => parseFloat(price.replace(".", ""))
|
||||||
|
|
||||||
|
|
||||||
|
// TODO we dont save images ??
|
||||||
|
|
||||||
|
// const images = [];
|
||||||
|
// const imgMatches = body.match(imgRe);
|
||||||
|
|
||||||
|
// for (let i = 0; imgMatches && i < imgMatches.length; i++) {
|
||||||
|
// let img = imgMatches[i].replace("href\":", "")
|
||||||
|
// img = img.replace("\"", "");
|
||||||
|
// img = img.replace("\"", "");
|
||||||
|
// images.push(img);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const uploadPromises = images.map(img => {
|
||||||
|
// const imgFixed = eval(`'${img}'`);
|
||||||
|
// return cloudinary.uploader.upload(eval(`'${img}'`));
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const uploadResults = await Promise.all(uploadPromises);
|
||||||
|
// const cloudinaryImages = uploadResults.map(ur => ur.url);
|
||||||
|
|
||||||
|
if (matches && matches.length >= 3) {
|
||||||
|
lat = matches[1];
|
||||||
|
lng = matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedPrice = parsePrice(price);
|
||||||
|
|
||||||
|
const locationArray = location.split(",");
|
||||||
|
const region = locationArray[0];
|
||||||
|
const municipality = locationArray[1];
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
realEstateType: this.getCategoryId(realEstateType),
|
||||||
|
email : email,
|
||||||
|
olxId: olxId,
|
||||||
|
// category: category,
|
||||||
|
url,
|
||||||
|
title,
|
||||||
|
price: isNaN(parsedPrice) ? 0 : parsedPrice,
|
||||||
|
size: parseFloat(size),
|
||||||
|
gardenSize: isNaN(parseFloat(gardenSize)) ? 0 : parseFloat(gardenSize),
|
||||||
|
address,
|
||||||
|
region,
|
||||||
|
municipality,
|
||||||
|
// adType: AD_TYPE_SALE,
|
||||||
|
time,
|
||||||
|
shortDescription: descriptions.first().text(),
|
||||||
|
longDescription: descriptions.last().text(),
|
||||||
|
lat,
|
||||||
|
lng,
|
||||||
|
loc: [parseFloat(lat), parseFloat(lng)],
|
||||||
|
// images: cloudinaryImages
|
||||||
|
};
|
||||||
|
|
||||||
|
return data;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Exception caught: ' + e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async indexPage(olxUrl, maxResults = 1000) {
|
||||||
|
try {
|
||||||
|
//TODO fix paging
|
||||||
|
// console.log('Starting to index page: ' + pageNr);
|
||||||
|
// const url = `http://www.olx.ba/pretraga?vrsta=samoprodaja&sort_order=desc&kategorija=23&sort_po=datum&kanton=9&stranica=${pageNr}`;
|
||||||
|
|
||||||
|
const res = await fetch(olxUrl.url);
|
||||||
|
const body = await res.text();
|
||||||
|
const $ = cheerio.load(body);
|
||||||
|
const hrefs = [];
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
$('#rezultatipretrage').find('.listitem').each((i, elem) => {
|
||||||
|
const href = $(elem).find('a').first().attr('href');
|
||||||
|
hrefs.push(href);
|
||||||
|
});
|
||||||
|
|
||||||
|
let actualNoOfResults = (hrefs.length <= maxResults) ? hrefs.length : maxResults;
|
||||||
|
|
||||||
|
for (let i = 0; i < hrefs.length; i++) {
|
||||||
|
console.log(`indexing: ${hrefs[i]}`);
|
||||||
|
|
||||||
|
const singleData = await this.indexSingle(hrefs[i], olxUrl.email);
|
||||||
|
|
||||||
|
if (singleData) {
|
||||||
|
results.push(singleData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Exception caught:' + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getCategoryId (category) {
|
||||||
|
|
||||||
|
switch(category) {
|
||||||
|
case 'Stanovi':
|
||||||
|
return 'stan';
|
||||||
|
|
||||||
|
case 'Vikendice':
|
||||||
|
return 'vikendica'
|
||||||
|
|
||||||
|
case 'Kuće':
|
||||||
|
return 'kuca';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async indexPages(urls, start, end, maxResults = 1000) {
|
||||||
|
//TODO fix paging
|
||||||
|
// let results = {};
|
||||||
|
// for (let i = start; i <= end; i++) {
|
||||||
|
// let result = await this.indexPage(i, maxResults);
|
||||||
|
// Object.assign(results, result)
|
||||||
|
// }
|
||||||
|
// return results;
|
||||||
|
|
||||||
|
let results = [];
|
||||||
|
for (let url of urls) {
|
||||||
|
let result = await this.indexPage(url, maxResults);
|
||||||
|
results.push(result);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
async crawl() {
|
||||||
|
|
||||||
|
const filteredResults = [];
|
||||||
|
const realestateRequests = await allRERequest()
|
||||||
|
const urls = this.createRequestUrls(realestateRequests);
|
||||||
|
let results = await this.indexPages(urls, this.fromPage, this.toPage, this.maxResults);
|
||||||
|
|
||||||
|
for (const result of results) {
|
||||||
|
for (const finalResult of result) {
|
||||||
|
if (finalResult.lat !== undefined && finalResult.lat !== null && finalResult.lat !== "") {
|
||||||
|
const pointInsideBoundingBox = await findPointInsideBoundingBox([finalResult.lng, finalResult.lat]);
|
||||||
|
|
||||||
|
if (pointInsideBoundingBox[0].length !== 0) {
|
||||||
|
filteredResults.push(finalResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(filteredResults);
|
||||||
|
return filteredResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
createRequestUrls(realestateRequests) {
|
||||||
|
const urls = []
|
||||||
|
|
||||||
|
for (const request of realestateRequests) {
|
||||||
|
const realsestateType = "kategorija=" + getRealEstateTypeEnum(request.realEstateType).olxCategory;
|
||||||
|
const region = "kanton=" + getRegion(request.region).olxid;
|
||||||
|
const municipality = "grad%5B%5D=" + getMunicipality(request.region, request.municipality).olxid;
|
||||||
|
const sizeMin = "kvadrata_min=" + request.sizeMin;
|
||||||
|
const sizeMax = "kvadrata_max=" + request.sizeMax;
|
||||||
|
const priceMin = "od=" + request.priceMin;
|
||||||
|
const priceMax = "do=" + request.priceMax;
|
||||||
|
|
||||||
|
const olxUrl = {
|
||||||
|
url: `https://www.olx.ba/pretraga?${realsestateType}&id=2&stanje=0&vrstapregleda=tabela&sort_order=desc&${region}&${municipality}&${priceMin}&${priceMax}&vrsta=samoprodaja&${sizeMin}&${sizeMax}`,
|
||||||
|
email: request.email
|
||||||
|
}
|
||||||
|
console.log(olxUrl.url);
|
||||||
|
urls.push(olxUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
15
app/helpers/db/dbHelper.js
Normal file
15
app/helpers/db/dbHelper.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
const db = require('../../models/index');
|
||||||
|
|
||||||
|
// TODO Fetch only subscribed realestate requests
|
||||||
|
const allRERequest = async () => {
|
||||||
|
return await db.RealEstateRequest.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
const findPointInsideBoundingBox = async (latLng) => {
|
||||||
|
return await db.sequelize.query("SELECT * FROM \"RealEstateRequests\" WHERE ST_Contains(\"RealEstateRequests\".bounding_box, ST_GEOMFROMTEXT(\'POINT (" + latLng[0] + " " + latLng[1]+ ")\'))");
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
allRERequest,
|
||||||
|
findPointInsideBoundingBox
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const realEstateTypes = [
|
const realEstateTypes = [
|
||||||
{ title: "Kuća", id: "kuca", hasGardenSize: true },
|
{ title: "Kuća", id: "kuca", hasGardenSize: true, olxCategory: 24 },
|
||||||
{ title: "Stan", id: "stan", hasGardenSize: false },
|
{ title: "Stan", id: "stan", hasGardenSize: false, olxCategory: 23},
|
||||||
{ title: "Vikendica", id: "vikendica", hasGardenSize: true }
|
{ title: "Vikendica", id: "vikendica", hasGardenSize: true, olxCategory: 26 }
|
||||||
];
|
];
|
||||||
|
|
||||||
const sizes = [
|
const sizes = [
|
||||||
|
|||||||
@@ -7,7 +7,17 @@ const currentRERequest = async (req) => {
|
|||||||
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
|
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
|
||||||
return request;
|
return request;
|
||||||
};
|
};
|
||||||
|
// TODO Fetch only subscribed realestate requests
|
||||||
|
const allRERequest = async () => {
|
||||||
|
return await db.RealEstateRequest.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
const findPointInsideBoundingBox = async (latLng) => {
|
||||||
|
return await db.sequelize.query("SELECT * FROM \"RealEstateRequests\" WHERE ST_Contains(\"RealEstateRequests\".bounding_box, ST_GEOMFROMTEXT(\'POINT (" + latLng[0] + " " + latLng[1]+ ")\'))");
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
currentRERequest
|
currentRERequest,
|
||||||
|
allRERequest,
|
||||||
|
findPointInsideBoundingBox
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const scrapTheItems = require("./scrapTheItems");
|
const scrapTheItems = require("./scrapTheItems");
|
||||||
const convertToDate = require("./convertToDate");
|
const convertToDate = require("./convertToDate");
|
||||||
const AWS = require('aws-sdk');
|
const AWS = require('aws-sdk');
|
||||||
AWS.config.update({region: 'eu-central-1'});
|
// AWS.config.update({region: 'eu-central-1'});
|
||||||
|
|
||||||
|
|
||||||
async function sendNotification(marketAlert) {
|
async function sendNotification(marketAlert) {
|
||||||
|
|||||||
27
app/migrations/20190529093410-slider-fields.js
Normal file
27
app/migrations/20190529093410-slider-fields.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'sizeRange', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
63
app/migrations/20190530101945-range-fields.js
Normal file
63
app/migrations/20190530101945-range-fields.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'size', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSize', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'price', { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMin', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMax', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'sizeMin', {
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'sizeMax', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceMin', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMin', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMax', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeMin', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeMax', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'size', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSize', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'price', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
18
app/migrations/20190531111232-subscribed-boolean.js
Normal file
18
app/migrations/20190531111232-subscribed-boolean.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.addColumn(
|
||||||
|
'RealEstateRequests',
|
||||||
|
'subscribed',
|
||||||
|
Sequelize.BOOLEAN
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.removeColumn(
|
||||||
|
'RealEstateRequests',
|
||||||
|
'subscribed'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
37
app/migrations/20190618103020-expand-maketalert.js
Normal file
37
app/migrations/20190618103020-expand-maketalert.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'size', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'gardenSize', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'price', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'municipality', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'region', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'size', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'gardenSize', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'price', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'municipality', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'region', { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'olxUrl', { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'url', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'realestateOrigin', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'originId', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'url', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'realestateOrigin', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('MarketAlerts', 'originId', { transaction: t }),
|
||||||
|
queryInterface.addColumn('MarketAlerts', 'olxUrl', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
20
app/migrations/20190621162321-add-category-to-marketalert.js
Normal file
20
app/migrations/20190621162321-add-category-to-marketalert.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.addColumn(
|
||||||
|
'MarketAlerts',
|
||||||
|
'realEstateType',
|
||||||
|
{
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.removeColumn(
|
||||||
|
'MarketAlerts',
|
||||||
|
'realEstateType'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const MarketAlert = sequelize.define('MarketAlert', {
|
const MarketAlert = sequelize.define('MarketAlert', {
|
||||||
olxUrl: DataTypes.STRING,
|
url: DataTypes.STRING,
|
||||||
|
realestateOrigin: DataTypes.STRING,
|
||||||
|
originId: DataTypes.STRING,
|
||||||
lastDate: DataTypes.STRING,
|
lastDate: DataTypes.STRING,
|
||||||
|
size : DataTypes.INTEGER,
|
||||||
|
gardenSize : DataTypes.INTEGER,
|
||||||
|
price : DataTypes.INTEGER,
|
||||||
|
municipality : DataTypes.STRING,
|
||||||
|
region : DataTypes.STRING,
|
||||||
|
realEstateType : DataTypes.STRING,
|
||||||
|
|
||||||
email: {
|
email: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNul: false
|
allowNul: false
|
||||||
|
|||||||
@@ -12,10 +12,14 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
email: DataTypes.STRING,
|
email: DataTypes.STRING,
|
||||||
region: DataTypes.STRING,
|
region: DataTypes.STRING,
|
||||||
municipality: DataTypes.STRING,
|
municipality: DataTypes.STRING,
|
||||||
size: DataTypes.STRING,
|
sizeMin: DataTypes.INTEGER,
|
||||||
gardenSize: DataTypes.STRING,
|
sizeMax: DataTypes.INTEGER,
|
||||||
price: DataTypes.STRING,
|
gardenSizeMin: DataTypes.INTEGER,
|
||||||
bounding_box: DataTypes.GEOMETRY('POINT', 4326)
|
gardenSizeMax: DataTypes.INTEGER,
|
||||||
|
priceMin: DataTypes.INTEGER,
|
||||||
|
priceMax: DataTypes.INTEGER,
|
||||||
|
bounding_box: DataTypes.GEOMETRY('POINT', 4326),
|
||||||
|
subscribed: DataTypes.BOOLEAN
|
||||||
}, {});
|
}, {});
|
||||||
RealEstateRequest.associate = function(models) {
|
RealEstateRequest.associate = function(models) {
|
||||||
// associations can be defined here
|
// associations can be defined here
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
color: rgba(0, 0, 0, 0);
|
color: rgba(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
.no-ui-slider {
|
||||||
|
width: 95%
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#map {
|
#map {
|
||||||
|
|||||||
55
app/services/crawlerService.js
Normal file
55
app/services/crawlerService.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
const Promise = require("bluebird");
|
||||||
|
const OlxCrawler = require("../helpers/crawlers/olxClawler");
|
||||||
|
const db = require("../models/index");
|
||||||
|
|
||||||
|
const olxCrawler = new OlxCrawler(1, 2, 3);
|
||||||
|
|
||||||
|
const crawlers = [
|
||||||
|
olxCrawler,
|
||||||
|
];
|
||||||
|
|
||||||
|
async function crawlAll() {
|
||||||
|
|
||||||
|
Promise.map(crawlers, function (crawler) {
|
||||||
|
return crawler.crawl();
|
||||||
|
}).then(async (results) => {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const marketAlertsFromDb = await db.MarketAlert.findAll();
|
||||||
|
|
||||||
|
const marketAlerts = [];
|
||||||
|
const mergedResults = [].concat.apply([], results);
|
||||||
|
|
||||||
|
for (const result of mergedResults) {
|
||||||
|
marketAlerts.push({
|
||||||
|
url: result.url,
|
||||||
|
realestateOrigin: "OLX",
|
||||||
|
originId: 1,
|
||||||
|
size: result.size,
|
||||||
|
price: result.price,
|
||||||
|
email: result.email,
|
||||||
|
// lastDate: DataTypes.STRING,
|
||||||
|
municipality: result.municipality,
|
||||||
|
region: result.region,
|
||||||
|
gardenSize: isNaN(result.gardenSize) ? 0 : result.gardenSize,
|
||||||
|
realEstateType: result.realEstateType
|
||||||
|
})
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
console.log(marketAlerts);
|
||||||
|
const filteredMarketAlerts = marketAlerts.filter((elem) => !marketAlertsFromDb.find(({ url }) => elem.url === url));
|
||||||
|
await db.MarketAlert.bulkCreate(filteredMarketAlerts);
|
||||||
|
process.exit()
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Could not bulkCreate marketalers reason: ", e);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error crawling. Trying next crawler! ", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
crawlAll();
|
||||||
|
|
||||||
@@ -3,27 +3,4 @@
|
|||||||
<h2>Koliko okućnice tražite ?</h2>
|
<h2>Koliko okućnice tražite ?</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST" id="form-gardensize">
|
<% include partials/range %>
|
||||||
<div class="row center-align">
|
|
||||||
<ul class="collection with-header">
|
|
||||||
<% for(const gardenSize of gardenSizes) { %>
|
|
||||||
<li class="collection-item" >
|
|
||||||
<div id="<%= gardenSize.id %>" onclick="saveAndSubmit(this.id)"><%= gardenSize.title %>
|
|
||||||
<a href="#" class="secondary-content">
|
|
||||||
<i class="material-icons">send</i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<% } %>
|
|
||||||
</ul>
|
|
||||||
<input type="hidden" name="gardensize" id="gardensize" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function saveAndSubmit(id) {
|
|
||||||
$("#gardensize").val(id);
|
|
||||||
$("#form-gardensize").submit();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/13.1.5/nouislider.min.css">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -13,5 +14,9 @@
|
|||||||
<%-body%>
|
<%-body%>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/13.1.5/nouislider.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/wnumb/1.1.0/wNumb.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2,89 +2,128 @@
|
|||||||
<h2>U kojem naselju tražite nekretninu?</h2>
|
<h2>U kojem naselju tražite nekretninu?</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row center-align" >
|
<div class="row center-align">
|
||||||
<div id="floating-panel">
|
<div id="floating-panel">
|
||||||
<input id="address" type="textbox" value="">
|
<input id="address" type="textbox" value="">
|
||||||
<input id="submit" type="button" value="Trazi">
|
<input id="submit" type="button" value="Trazi">
|
||||||
</div>
|
</div>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
</div>
|
</div>
|
||||||
<form method="POST" id="form-map-output">
|
<form method="POST" id="form-map-output">
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
<div class="col s6 push-s3">
|
<div class="col s6 push-s3">
|
||||||
<a id="btnsubmit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
<a id="btnsubmit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
||||||
Dalje
|
Dalje
|
||||||
</a>
|
</a>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="north" id=north />
|
</div>
|
||||||
<input type="hidden" name="south" id=south />
|
<input type="hidden" name="north" id=north />
|
||||||
<input type="hidden" name="east" id=east />
|
<input type="hidden" name="south" id=south />
|
||||||
<input type="hidden" name="west" id=west />
|
<input type="hidden" name="east" id=east />
|
||||||
</form>
|
<input type="hidden" name="west" id=west />
|
||||||
<script>
|
</form>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
var map;
|
var map;
|
||||||
var municipality = "<%= municipality%>";
|
var municipality = "<%= municipality%>";
|
||||||
var defaultAddress = document.getElementById('address');
|
var defaultAddress = document.getElementById('address');
|
||||||
|
var latLngRestrictions = [];
|
||||||
|
|
||||||
var BOSNIA_BOUNDS = {
|
var BOSNIA_BOUNDS = {
|
||||||
north: 45.70,
|
north: 45.70,
|
||||||
south: 41.69,
|
south: 41.69,
|
||||||
west: 15.55,
|
west: 15.55,
|
||||||
east: 20.77,
|
east: 20.77,
|
||||||
};
|
};
|
||||||
|
|
||||||
function initMap() {
|
function initMap() {
|
||||||
map = new google.maps.Map(document.getElementById('map'), {
|
var geocoder = new google.maps.Geocoder();
|
||||||
center: { lat: -34.397, lng: 150.644 },
|
|
||||||
zoom: 11,
|
document.getElementById('submit').addEventListener('click', function () {
|
||||||
restriction: {
|
geocodeAddress(geocoder, map, false, latLngRestrictions);
|
||||||
latLngBounds: BOSNIA_BOUNDS,
|
});
|
||||||
strictBounds: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
defaultAddress.value = municipality;
|
||||||
|
geocodeAddress(geocoder, map, true);
|
||||||
|
|
||||||
|
$(document).ready(() => {
|
||||||
|
$("#btnsubmit").click(() => {
|
||||||
|
var bounds = map.getBounds();
|
||||||
|
|
||||||
|
$("#north").val(map.getBounds().getNorthEast().lat());
|
||||||
|
$("#south").val(map.getBounds().getSouthWest().lat());
|
||||||
|
$("#east").val(map.getBounds().getNorthEast().lng());
|
||||||
|
$("#west").val(map.getBounds().getSouthWest().lng());
|
||||||
|
|
||||||
|
$("#form-map-output").submit();
|
||||||
});
|
});
|
||||||
var geocoder = new google.maps.Geocoder();
|
});
|
||||||
|
|
||||||
document.getElementById('submit').addEventListener('click', function () {
|
|
||||||
geocodeAddress(geocoder, map);
|
|
||||||
});
|
|
||||||
|
|
||||||
function geocodeAddress(geocoder, resultsMap) {
|
}
|
||||||
var address = document.getElementById('address').value;
|
|
||||||
geocoder.geocode({ 'address': address }, function (results, status) {
|
function geocodeAddress(geocoder, resultsMap, isInit, geocoderRestrictions) {
|
||||||
if (status === 'OK') {
|
|
||||||
resultsMap.setCenter(results[0].geometry.location);
|
|
||||||
var marker = new google.maps.Marker({
|
|
||||||
map: resultsMap,
|
var address = document.getElementById('address').value;
|
||||||
position: results[0].geometry.location
|
let geocoderOptions = geocoderRestrictions
|
||||||
});
|
? { 'address': address, 'bounds': geocoderRestrictions }
|
||||||
} else {
|
: { 'address': address }
|
||||||
alert('Geocode was not successful for the following reason: ' + status);
|
|
||||||
|
geocoder.geocode(geocoderOptions, function (results, status) {
|
||||||
|
if (status === 'OK') {
|
||||||
|
|
||||||
|
var bounds = results[0].geometry.bounds;
|
||||||
|
|
||||||
|
var resultBounds = new google.maps.LatLngBounds(
|
||||||
|
|
||||||
|
results[0].geometry.viewport.getSouthWest(),
|
||||||
|
results[0].geometry.viewport.getNorthEast()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInit) {
|
||||||
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
zoom: 11,
|
||||||
|
});
|
||||||
|
resultsMap = map
|
||||||
|
}
|
||||||
|
|
||||||
|
// map.fitBounds(resultBounds);
|
||||||
|
resultsMap.setCenter(results[0].geometry.location);
|
||||||
|
|
||||||
|
if (isInit) {
|
||||||
|
|
||||||
|
latLngRestrictions = new google.maps.LatLngBounds(
|
||||||
|
new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()),
|
||||||
|
new google.maps.LatLng(bounds.getNorthEast().lng(), bounds.getNorthEast().lng()));
|
||||||
|
|
||||||
|
|
||||||
|
let latLngRestrictionsa = {
|
||||||
|
west: bounds.getSouthWest().lng(),
|
||||||
|
east: bounds.getNorthEast().lng(),
|
||||||
|
north: bounds.getNorthEast().lat(),
|
||||||
|
south: bounds.getSouthWest().lat()
|
||||||
}
|
}
|
||||||
});
|
map.setOptions({
|
||||||
|
restriction: {
|
||||||
|
latLngBounds: latLngRestrictionsa,
|
||||||
|
strictBounds: false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
resultsMap.setZoom(17);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert('Geocode was not successful for the following reason: ' + status);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
defaultAddress.value = municipality;
|
}
|
||||||
geocodeAddress(geocoder, map);
|
</script>
|
||||||
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAna8ohfV2HBMcxGk_29vqxU5Z_bDickqg&callback=initMap" async
|
||||||
$(document).ready(() => {
|
defer></script>
|
||||||
$("#btnsubmit").click(() => {
|
|
||||||
var bounds = map.getBounds();
|
|
||||||
|
|
||||||
$("#north").val(bounds.na.l);
|
|
||||||
$("#south").val(bounds.na.j);
|
|
||||||
$("#east").val(bounds.ia.l);
|
|
||||||
$("#west").val(bounds.ia.j);
|
|
||||||
|
|
||||||
$("#form-map-output").submit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAna8ohfV2HBMcxGk_29vqxU5Z_bDickqg&callback=initMap"
|
|
||||||
async defer></script>
|
|
||||||
</div>
|
</div>
|
||||||
53
app/views/partials/range.ejs
Normal file
53
app/views/partials/range.ejs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<form method="POST" id="form-range">
|
||||||
|
|
||||||
|
<div class="row center-align no-ui-slider" id="slider"></div>
|
||||||
|
|
||||||
|
<div class="col s6 push-s3">
|
||||||
|
<a id="btnsubmit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
||||||
|
Dalje
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" name="from" id="from" />
|
||||||
|
<input type="hidden" name="to" id="to" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
$(document).ready(() => {
|
||||||
|
|
||||||
|
var slider = document.getElementById('slider');
|
||||||
|
|
||||||
|
const unitFormat = wNumb({
|
||||||
|
decimals: 3,
|
||||||
|
thousand: '.',
|
||||||
|
suffix: '<%= unit %>'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
noUiSlider.create(slider, {
|
||||||
|
start: [<%= rangeFrom.value %>, <%= rangeTo.value %>],
|
||||||
|
connect: true,
|
||||||
|
tooltips: true,
|
||||||
|
step: <%= rangeFrom.step %>,
|
||||||
|
range: {
|
||||||
|
'min': <%= rangeFrom.min %>,
|
||||||
|
'max': <%= rangeTo.max %>
|
||||||
|
},
|
||||||
|
format: unitFormat
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("#btnsubmit").click(() => {
|
||||||
|
const sliderValues = slider.noUiSlider.get();
|
||||||
|
|
||||||
|
$("#from").val(unitFormat.from(sliderValues[0]));
|
||||||
|
$("#to").val(unitFormat.from(sliderValues[1]));
|
||||||
|
|
||||||
|
$("#form-range").submit();
|
||||||
|
// });
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -3,27 +3,4 @@
|
|||||||
<h2>Koja Vam okvirna cijena odgovara ?</h2>
|
<h2>Koja Vam okvirna cijena odgovara ?</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST" id="form-price">
|
<% include partials/range %>
|
||||||
<div class="row center-align">
|
|
||||||
<ul class="collection with-header">
|
|
||||||
<% for(const price of prices) { %>
|
|
||||||
<li class="collection-item" >
|
|
||||||
<div id="<%= price.id %>" onclick="saveAndSubmit(this.id)"><%= price.title %>
|
|
||||||
<a href="#" class="secondary-content">
|
|
||||||
<i class="material-icons">send</i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<% } %>
|
|
||||||
</ul>
|
|
||||||
<input type="hidden" name="price" id="price" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function saveAndSubmit(id) {
|
|
||||||
$("#price").val(id);
|
|
||||||
$("#form-price").submit();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,25 @@
|
|||||||
<input id="email" name="email" type="email" placeholder="vas.email@mail.com" required size="250" />
|
<input id="email" name="email" type="email" placeholder="vas.email@mail.com" required size="250" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if (error) {%>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s6 push-s3">
|
<div class="col s6 push-s3">
|
||||||
<h6 style="color: red">Greška ! Unesite ispravan email</h6>
|
<h6 id="error-lable-email" style="color: red"><%= error %> </h6>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<%}%>
|
</div>
|
||||||
|
|
||||||
|
<div class="row center-align">
|
||||||
|
<div class="col s6 push-s3">
|
||||||
|
<input id="confirm" name="confirm" type="email" placeholder="potvrdite.email@mail.com" required size="250" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s6 push-s3">
|
||||||
|
<h6 id="error-lable-email-confirm" style="color: red"></h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s6 push-s3">
|
<div class="col s6 push-s3">
|
||||||
<a id="submit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
<a id="submit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
||||||
@@ -31,13 +43,26 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready( () => {
|
$(document).ready(() => {
|
||||||
$("#submit").click( () => {
|
$("#submit").click(() => {
|
||||||
const emailField = document.getElementById('email');
|
const emailField = document.getElementById('email');
|
||||||
if (emailField.validity.valid){
|
const emailConfirmField = document.getElementById('confirm');
|
||||||
$("#form-submitquery").submit();
|
const errorMessage = "Greška ! Unedite validan email";
|
||||||
}
|
$("#error-lable-email").text("");
|
||||||
});
|
$("#error-lable-email-confirm").text("");
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
if (!emailField.validity.valid) {
|
||||||
|
$("#error-lable-email").text(errorMessage);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!emailConfirmField.validity.valid) {
|
||||||
|
$("#error-lable-email-confirm").text(errorMessage);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#form-submitquery").submit();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -1,29 +1,6 @@
|
|||||||
<!--suppress HtmlUnknownAnchorTarget -->
|
<!--suppress HtmlUnknownAnchorTarget -->
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
<h2>Do koliko kvadrata tražite nekretninu ?</h2>
|
<h2>Od koliko kvadrata tražite nekretninu ?</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST" id="form-size">
|
<% include partials/range %>
|
||||||
<div class="row center-align">
|
|
||||||
<ul class="collection with-header">
|
|
||||||
<% for(const size of sizes) { %>
|
|
||||||
<li class="collection-item">
|
|
||||||
<div id="<%= size.id %>" onclick="saveAndSubmit(this.id)"><%= size.title %>
|
|
||||||
<a href="#" class="secondary-content">
|
|
||||||
<i class="material-icons">send</i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<% } %>
|
|
||||||
</ul>
|
|
||||||
<input type="hidden" name="size" id="size" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function saveAndSubmit(id) {
|
|
||||||
$("#size").val(id);
|
|
||||||
$("#form-size").submit();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|||||||
14
app/views/unsubscribe.ejs
Normal file
14
app/views/unsubscribe.ejs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
<div class="row center-align">
|
||||||
|
<span class="welcome-big-logo">🤙</span>
|
||||||
|
</div>
|
||||||
|
<div class="row center-align">
|
||||||
|
<div>Uspješno ste se odjavili</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s6 push-s3">
|
||||||
|
<a href="<%= nextStep %>" class="welcome-center-button waves-effect waves-light btn">
|
||||||
|
Nova pretraga
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
5
development.env
Normal file
5
development.env
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
AMAZON_ACCES_KEY_ID=(your-key-here)
|
||||||
|
AMAZON_SECRET_ACCESS_KEY=(your-key-here)
|
||||||
|
AMAZON_REGION=eu-west-1
|
||||||
|
APP_URL=http://localhost:3001
|
||||||
|
SOURCE_EMAIL=info@saburly.com
|
||||||
7
index.js
7
index.js
@@ -1,5 +1,5 @@
|
|||||||
const welcome = require('./app/controllers/welcome').getWelcome;
|
const welcome = require('./app/controllers/welcome').getWelcome;
|
||||||
const { getRealEstateTypes, postRealEstateTypes} = require('./app/controllers/realEstateTypes');
|
const { getRealEstateTypes, postRealEstateTypes } = require('./app/controllers/realEstateTypes');
|
||||||
const { getRegion, postRegion } = require('./app/controllers/regions');
|
const { getRegion, postRegion } = require('./app/controllers/regions');
|
||||||
const { getMunicipality, postMunicipality } = require('./app/controllers/municipalities');
|
const { getMunicipality, postMunicipality } = require('./app/controllers/municipalities');
|
||||||
const { getSize, postSize } = require('./app/controllers/sizes');
|
const { getSize, postSize } = require('./app/controllers/sizes');
|
||||||
@@ -9,6 +9,7 @@ const { getQueryReview, postQueryReview } = require('./app/controllers/queryRevi
|
|||||||
const { getQuerySubmit, postQuerySubmit } = require('./app/controllers/querySubmit');
|
const { getQuerySubmit, postQuerySubmit } = require('./app/controllers/querySubmit');
|
||||||
const { getGoAgain } = require('./app/controllers/goAgain');
|
const { getGoAgain } = require('./app/controllers/goAgain');
|
||||||
const { getNeighborhood, postNeighborhood } = require('./app/controllers/neighborhoodMap');
|
const { getNeighborhood, postNeighborhood } = require('./app/controllers/neighborhoodMap');
|
||||||
|
const { getUnsubscribe } = require('./app/controllers/unsubscribe');
|
||||||
|
|
||||||
let express = require("express");
|
let express = require("express");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@@ -106,7 +107,7 @@ app.post("/api/payforalert", (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tco.checkout.authorize(params, function(error, data) {
|
tco.checkout.authorize(params, function (error, data) {
|
||||||
if (error) {
|
if (error) {
|
||||||
res.send(error.message);
|
res.send(error.message);
|
||||||
} else {
|
} else {
|
||||||
@@ -146,6 +147,8 @@ app.post('/pregled/:request_id', postQueryReview);
|
|||||||
app.get('/posalji/:request_id', getQuerySubmit);
|
app.get('/posalji/:request_id', getQuerySubmit);
|
||||||
app.post('/posalji/:request_id', postQuerySubmit);
|
app.post('/posalji/:request_id', postQuerySubmit);
|
||||||
|
|
||||||
|
app.get('/odjava/:request_id', getUnsubscribe);
|
||||||
|
|
||||||
app.get('/ponovo', getGoAgain);
|
app.get('/ponovo', getGoAgain);
|
||||||
|
|
||||||
app.use('/assets', express.static('./app/public'));
|
app.use('/assets', express.static('./app/public'));
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -327,9 +327,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.5.3",
|
"version": "3.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz",
|
||||||
"integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw=="
|
"integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w=="
|
||||||
},
|
},
|
||||||
"body-parser": {
|
"body-parser": {
|
||||||
"version": "1.18.3",
|
"version": "1.18.3",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node ./index.js",
|
"start": "node ./index.js",
|
||||||
"start-mon": "nodemon ./index.js",
|
"start-mon": "nodemon ./index.js",
|
||||||
|
"scheduler": "node ./app/services/crawlerService.js",
|
||||||
"migrate": "cd app && npx sequelize db:migrate",
|
"migrate": "cd app && npx sequelize db:migrate",
|
||||||
"setup": "docker build -t marketalerts . && docker run -e POSTGRES_USER=docker -e POSTGRES_PASSWORD=docker -e POSTGRES_DB=marketalerts --name pg_marketalerts -d -p 5432:5432 marketalerts && sleep 4 && npm run migrate",
|
"setup": "docker build -t marketalerts . && docker run -e POSTGRES_USER=docker -e POSTGRES_PASSWORD=docker -e POSTGRES_DB=marketalerts --name pg_marketalerts -d -p 5432:5432 marketalerts && sleep 4 && npm run migrate",
|
||||||
"docker-start": "docker start pg_marketalerts",
|
"docker-start": "docker start pg_marketalerts",
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
"2checkout-node": "0.0.1",
|
"2checkout-node": "0.0.1",
|
||||||
"@sendgrid/mail": "^6.3.1",
|
"@sendgrid/mail": "^6.3.1",
|
||||||
"aws-sdk": "^2.422.0",
|
"aws-sdk": "^2.422.0",
|
||||||
|
"bluebird": "^3.5.5",
|
||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"dotenv": "^7.0.0",
|
"dotenv": "^7.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user