Email links now point to our URL and then redirect to the original property URL, ran prettier on the affected files
This commit is contained in:
@@ -1,90 +1,106 @@
|
||||
const db = require('../../models/index');
|
||||
const db = require("../../models/index");
|
||||
|
||||
/**
|
||||
* Find all subscribed RealEstateRequests
|
||||
* Find all subscribed RealEstateRequests
|
||||
*/
|
||||
const allRERequest = async () => {
|
||||
return await db.RealEstateRequest.findAll({
|
||||
where: {
|
||||
subscribed: true
|
||||
}
|
||||
});
|
||||
}
|
||||
return await db.RealEstateRequest.findAll({
|
||||
where: {
|
||||
subscribed: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all subscribed RealEstateRequests by UUID
|
||||
*/
|
||||
const allRERequestByUiid = async (requestArray) => {
|
||||
|
||||
const allRERequestByUiid = async requestArray => {
|
||||
const Op = db.Sequelize.Op;
|
||||
return await db.RealEstateRequest.findAll({
|
||||
where: {
|
||||
subscribed: true,
|
||||
[Op.or]: requestArray
|
||||
}
|
||||
});
|
||||
}
|
||||
where: {
|
||||
subscribed: true,
|
||||
[Op.or]: requestArray
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all , or all depending on notified bolean marketalerts, that the hasLocation is true, and order them by email
|
||||
*
|
||||
*
|
||||
* @param fechAll bolean
|
||||
* @param notified bolean
|
||||
*
|
||||
*
|
||||
* @returns array of MarketAlerts
|
||||
*/
|
||||
const allMarketAlerts = async (fetchAll, notified) => {
|
||||
|
||||
let queryObject = {
|
||||
order: [
|
||||
['email', 'DESC'],
|
||||
]
|
||||
}
|
||||
|
||||
if (!fetchAll){
|
||||
queryObject.where = {
|
||||
notified: notified,
|
||||
hasLocation: true
|
||||
}
|
||||
}
|
||||
|
||||
return await db.MarketAlert.findAll(queryObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all , MarketAlerts depending on request
|
||||
*
|
||||
* @param request string
|
||||
*
|
||||
* @returns array of MarketAlerts
|
||||
*/
|
||||
const allMarketAlertsByRequest = async (request) => {
|
||||
|
||||
let queryObject = {
|
||||
where : {
|
||||
request: request
|
||||
}
|
||||
order: [["email", "DESC"]]
|
||||
};
|
||||
|
||||
if (!fetchAll) {
|
||||
queryObject.where = {
|
||||
notified: notified,
|
||||
hasLocation: true
|
||||
};
|
||||
}
|
||||
|
||||
return await db.MarketAlert.findAll(queryObject);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Find all unnotified marketalerts
|
||||
* Find all , MarketAlerts depending on request
|
||||
*
|
||||
* @param request string
|
||||
*
|
||||
* @returns array of MarketAlerts
|
||||
*/
|
||||
const allMarketAlertsByRequest = async request => {
|
||||
let queryObject = {
|
||||
where: {
|
||||
request: request
|
||||
}
|
||||
};
|
||||
|
||||
return await db.MarketAlert.findAll(queryObject);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find MarketAlerts by id
|
||||
*
|
||||
* @param id number
|
||||
*
|
||||
* @returns single MarketAlert
|
||||
*/
|
||||
const getMarketAlertById = async id => {
|
||||
let queryObject = {
|
||||
where: {
|
||||
id: id
|
||||
}
|
||||
};
|
||||
|
||||
return await db.MarketAlert.findOne(queryObject);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all unnotified marketalerts
|
||||
* @param latLng array
|
||||
* @param email string
|
||||
*
|
||||
*
|
||||
* @returns array of MarketAlerts
|
||||
*/
|
||||
const findPointInsideBoundingBox = async (latLng, email, uniqueId) => {
|
||||
return await db.sequelize.query(`SELECT * FROM "RealEstateRequests" WHERE email = '${email}' AND "uniqueId" = '${uniqueId}' AND subscribed = true AND ST_Contains("RealEstateRequests".bounding_box, ST_GEOMFROMTEXT('POINT (${latLng[0]} ${latLng[1]})'))`);
|
||||
}
|
||||
return await db.sequelize.query(
|
||||
`SELECT * FROM "RealEstateRequests" WHERE email = '${email}' AND "uniqueId" = '${uniqueId}' AND subscribed = true AND ST_Contains("RealEstateRequests".bounding_box, ST_GEOMFROMTEXT('POINT (${
|
||||
latLng[0]
|
||||
} ${latLng[1]})'))`
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
allRERequest,
|
||||
allMarketAlerts,
|
||||
allRERequestByUiid,
|
||||
findPointInsideBoundingBox,
|
||||
allMarketAlertsByRequest
|
||||
allMarketAlertsByRequest,
|
||||
getMarketAlertById
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user