mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* 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 };
|