Add email frequency option #68

Merged
bilal.catic merged 10 commits from add-email-frequency-option into master 2019-11-04 14:28:46 +01:00
Showing only changes of commit 5b2961d992 - Show all commits

View File

@@ -24,6 +24,23 @@ const findRealEstatesForSearchRequest = async searchRequestId => {
return matchingRealEstates;
};
const findNotNotifiedMatches = async () => {
const query = {
notified: false
};
const searchRequestsModel = { model: db.SearchRequest, as: "searchRequests" };
const realEstateModel = { model: db.RealEstate, as: "realEstates" };
const include = [searchRequestsModel, realEstateModel];
const matchingRecords = await db.SearchRequestMatch.findAll({
where: query,
include
});
return matchingRecords;
};
const addMatches = async matchingRecords => {
return await db.SearchRequestMatch.bulkCreate(matchingRecords, {
ignoreDuplicates: true
@@ -32,5 +49,6 @@ const addMatches = async matchingRecords => {
module.exports = {
findRealEstatesForSearchRequest,
addMatches
addMatches,
findNotNotifiedMatches
};