Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-12 12:39:17 +08:00
parent 82ea9c77c4
commit ea3e82e54c
47 changed files with 1301 additions and 481 deletions
+25
View File
@@ -0,0 +1,25 @@
/***********************************************************************************************************************************************************************
* File Name : notificationVisibility.util.js
* Type : Utility
* Description : Shared visibility-window filter for AdminNotification/
* UserNotification rows carrying a denormalized start_date/
* end_date (copied from NotificationBroadcast at send time —
* see notificationBroadcasts.controller.js#sendBroadcast).
* Non-announcement notifications have both columns null, so
* this filter is a no-op for them.
*
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Jul. 11, 2026
***********************************************************************************************************************************************************************/
const { Op } = require('sequelize');
function notInFutureOrExpired(now = new Date()) {
return {
[Op.and]: [
{ [Op.or]: [{ start_date: null }, { start_date: { [Op.lte]: now } }] },
{ [Op.or]: [{ end_date: null }, { end_date: { [Op.gte]: now } }] },
],
};
}
module.exports = { notInFutureOrExpired };