```js async generateHash({ bound: { date_from, date_to, duration_bucket, max_stops, max_duration, }, travelClass, fromAir, toAir, }) { const diff = Math.abs( differenceInDays(new Date(date_from), new Date(date_to)), ); // console.log('THIS IS DIFFERENCE', diff); const hashes = new Map(); for (let i = 0; i <= diff; i += 1) { const journeyDate = format( addDays(new Date(date_from), i), 'yyyy-MM-dd', ); for (let j = 0; j < 4; j += 1) { if (duration_bucket[j]) { hashes.set( `${fromAir}~${toAir}~${journeyDate}~${j + 1 }~${max_stops}~${max_duration}~${travelClass}`, { date: journeyDate, time_bucket: j + 1, }, ); } } } console.log('THIS IS HASHES', hashes); const SELECT_HASH_QUERY = `SELECT alert_id,time_bucket,date,travel_class FROM buyhatke_flights.test_alerts_list2 WHERE from_air =${fromAir} AND to_air=${toAir} AND time_bucket in (${Array.from(hashes.keys()).map( (id) => hashes.get(id).time_bucket, )}) AND date in (${Array.from(hashes.keys()).map( (id) => `'${hashes.get(id).date}'`, )}) AND max_stops = ${max_stops} AND max_duration=${max_duration} AND travel_class = ${travelClass} AND active = 1;`; // console.log(SELECT_HASH_QUERY); const hashResult = await commonQuery(SELECT_HASH_QUERY); // const hashResult = [] ; // console.log("previos hashes",hashResult,"previous hashes") ; // console.log('THIS IS HASH RESULTS', hashResult); const alertIds = []; for (let i = 0; i < hashResult.length; i += 1) { const { time_bucket, date, alert_id, travel_class, } = hashResult[i]; const hashId = `${fromAir}~${toAir}~${format( new Date(date), 'yyyy-MM-dd', )}~${time_bucket}~${max_stops}~${max_duration}~${travel_class}`; // console.log('check this hash', hash_id); const entry = hashes.get(hashId); if (entry) { hashes.set(hashId, { ...entry, flag: 1 }); alertIds.push(alert_id); } } // console.log("after puuting flags",hashes); for (const id of hashes.keys()) { const { date, time_bucket, flag } = hashes.get(id); // console.log(date, time_bucket, flag, 'haha flag'); if (!flag) { // console.log("aara kya andar"); const object_to_push = { from_air: fromAir, to_air: toAir, date, max_stops, max_duration, time_bucket, travel_class: travelClass, }; const INSERT_QUERY = 'INSERT INTO buyhatke_flights.test_alerts_list2 SET ?'; const { insertId } = await commonQuery( INSERT_QUERY, object_to_push, ); alertIds.push(insertId); // console.log(object_to_push) ; } } return { data: alertIds, error: null }; } ```