From 4713e78d5138a1bab8e523be070a4b5c0e796bf9 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Mon, 30 Sep 2019 12:08:37 +0200 Subject: [PATCH] remove obsolete DB helper functions --- app/helpers/db/dbHelper.js | 106 ------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 app/helpers/db/dbHelper.js diff --git a/app/helpers/db/dbHelper.js b/app/helpers/db/dbHelper.js deleted file mode 100644 index d5288be..0000000 --- a/app/helpers/db/dbHelper.js +++ /dev/null @@ -1,106 +0,0 @@ -const db = require("../../models/index"); - -/** - * Find all subscribed RealEstateRequests - */ -const allRERequest = async () => { - return await db.RealEstateRequest.findAll({ - where: { - subscribed: true - } - }); -}; - -/** - * Find all subscribed RealEstateRequests by UUID - */ -const allRERequestByUiid = async requestArray => { - const Op = db.Sequelize.Op; - return await db.RealEstateRequest.findAll({ - 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 - } - }; - - 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"."boundingBox", ST_GEOMFROMTEXT('POINT (${ - latLng[0] - } ${latLng[1]})'))` - ); -}; - -module.exports = { - allRERequest, - allMarketAlerts, - allRERequestByUiid, - findPointInsideBoundingBox, - allMarketAlertsByRequest, - getMarketAlertById -};