Merge branch 'add-google-analytics' into 'master'
Add google analytics See merge request saburly/marketalarm/web!38
This commit was merged in pull request #38.
This commit is contained in:
@@ -11,6 +11,30 @@ const redirect = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
const getRedirect = async (req, res) => {
|
||||||
redirect
|
const id = req.params.id || null;
|
||||||
|
let error = false;
|
||||||
|
let redirectUrl = undefined;
|
||||||
|
if (!id) {
|
||||||
|
error = true;
|
||||||
|
} else {
|
||||||
|
const realEstate = await getRealEstateById(id);
|
||||||
|
if (!realEstate) {
|
||||||
|
error = true;
|
||||||
|
} else {
|
||||||
|
redirectUrl = realEstate.url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
const title = "";
|
||||||
|
res.render("notFound", { title });
|
||||||
|
} else {
|
||||||
|
const title = "Preusmjeravanje";
|
||||||
|
res.render("redirect", { title, redirectUrl });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getRedirect
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ class PostgresSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save(results) {
|
async save(results) {
|
||||||
console.log("[POSTGRES] Saving...");
|
|
||||||
|
|
||||||
const savedRecords = await bulkUpsertRealEstates(results);
|
const savedRecords = await bulkUpsertRealEstates(results);
|
||||||
|
|
||||||
if (Array.isArray(savedRecords)) {
|
if (Array.isArray(savedRecords)) {
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ class OlxCrawler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async crawl() {
|
async crawl() {
|
||||||
console.log("[OLX] Crawler started");
|
|
||||||
const crawlAdCategories = this.crawlerAdCategories;
|
const crawlAdCategories = this.crawlerAdCategories;
|
||||||
|
|
||||||
const newRealEstates = [];
|
const newRealEstates = [];
|
||||||
@@ -123,7 +122,6 @@ class OlxCrawler {
|
|||||||
await this.sleep(this.delayBetweenPages);
|
await this.sleep(this.delayBetweenPages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("[OLX] Crawler finished");
|
|
||||||
return newRealEstates;
|
return newRealEstates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const { getGoAgain } = require("../controllers/goAgain");
|
|||||||
const { getLocation, postLocation } = require("../controllers/location");
|
const { getLocation, postLocation } = require("../controllers/location");
|
||||||
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
||||||
const { getRealEstates } = require("../controllers/realEstates");
|
const { getRealEstates } = require("../controllers/realEstates");
|
||||||
const { redirect } = require("../controllers/redirect");
|
const { getRedirect } = require("../controllers/redirect");
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -50,6 +50,6 @@ router.get("/ponovo", getGoAgain);
|
|||||||
|
|
||||||
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
||||||
|
|
||||||
router.get("/redirect/:id", redirect);
|
router.get("/redirect/:id", getRedirect);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ const notifyMatches = async matches => {
|
|||||||
|
|
||||||
const sendEmailPromise = sendEmail(email, "Nove nekretnine", emailContent);
|
const sendEmailPromise = sendEmail(email, "Nove nekretnine", emailContent);
|
||||||
asyncSendEmailActions.push(sendEmailPromise);
|
asyncSendEmailActions.push(sendEmailPromise);
|
||||||
sendEmailPromise
|
sendEmailPromise.catch(err => console.log("[Email Sending Failed]", err));
|
||||||
.then(res => console.log(res))
|
|
||||||
.catch(err => console.log(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(asyncSendEmailActions);
|
await Promise.all(asyncSendEmailActions);
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
<!doctype>
|
<!doctype>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-149713678-1"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'UA-149713678-1');
|
||||||
|
</script>
|
||||||
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
|
||||||
<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">
|
||||||
|
|||||||
9
app/views/notFound.ejs
Normal file
9
app/views/notFound.ejs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<!--suppress HtmlUnknownAnchorTarget -->
|
||||||
|
<% include partials/navBar %>
|
||||||
|
|
||||||
|
<div class="row center">
|
||||||
|
<h4>Ups...stranica ne postoji</h4>
|
||||||
|
</div>
|
||||||
|
<div class="row center">
|
||||||
|
<h5><a href="/">Nova pretraga</a></h5>
|
||||||
|
</div>
|
||||||
28
app/views/redirect.ejs
Normal file
28
app/views/redirect.ejs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!--suppress HtmlUnknownAnchorTarget -->
|
||||||
|
<% include partials/navBar %>
|
||||||
|
|
||||||
|
<div class="center">
|
||||||
|
<div class="preloader-wrapper big active center">
|
||||||
|
<div class="spinner-layer spinner-green-only">
|
||||||
|
<div class="circle-clipper left">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="gap-patch">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="circle-clipper right">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="center">
|
||||||
|
<h6>
|
||||||
|
<a href="<%= redirectUrl %>" rel="noreferrer" id="realEstateUrl">Kliknite ovdje ako Vas web preglednik ne preusmjeri automatski</a>
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
window.onload = () => {
|
||||||
|
document.getElementById('realEstateUrl').click();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user