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 = {
|
||||
redirect
|
||||
const getRedirect = async (req, res) => {
|
||||
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) {
|
||||
console.log("[POSTGRES] Saving...");
|
||||
|
||||
const savedRecords = await bulkUpsertRealEstates(results);
|
||||
|
||||
if (Array.isArray(savedRecords)) {
|
||||
|
||||
@@ -55,7 +55,6 @@ class OlxCrawler {
|
||||
}
|
||||
|
||||
async crawl() {
|
||||
console.log("[OLX] Crawler started");
|
||||
const crawlAdCategories = this.crawlerAdCategories;
|
||||
|
||||
const newRealEstates = [];
|
||||
@@ -123,7 +122,6 @@ class OlxCrawler {
|
||||
await this.sleep(this.delayBetweenPages);
|
||||
}
|
||||
}
|
||||
console.log("[OLX] Crawler finished");
|
||||
return newRealEstates;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const { getGoAgain } = require("../controllers/goAgain");
|
||||
const { getLocation, postLocation } = require("../controllers/location");
|
||||
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
||||
const { getRealEstates } = require("../controllers/realEstates");
|
||||
const { redirect } = require("../controllers/redirect");
|
||||
const { getRedirect } = require("../controllers/redirect");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -50,6 +50,6 @@ router.get("/ponovo", getGoAgain);
|
||||
|
||||
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
||||
|
||||
router.get("/redirect/:id", redirect);
|
||||
router.get("/redirect/:id", getRedirect);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -40,9 +40,7 @@ const notifyMatches = async matches => {
|
||||
|
||||
const sendEmailPromise = sendEmail(email, "Nove nekretnine", emailContent);
|
||||
asyncSendEmailActions.push(sendEmailPromise);
|
||||
sendEmailPromise
|
||||
.then(res => console.log(res))
|
||||
.catch(err => console.log(err));
|
||||
sendEmailPromise.catch(err => console.log("[Email Sending Failed]", err));
|
||||
}
|
||||
|
||||
await Promise.all(asyncSendEmailActions);
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<!doctype>
|
||||
<html>
|
||||
<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/icon?family=Material+Icons" rel="stylesheet">
|
||||
<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