Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/note.picotech.app/public_html/src/models/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Meeting = sequelize.define('Meeting', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: {
type: DataTypes.STRING(255),
allowNull: false,
validate: {
len: [1, 255],
},
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
start_time: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
end_time: {
type: DataTypes.DATE,
allowNull: true,
},
status: {
type: DataTypes.ENUM('active', 'completed', 'cancelled'),
defaultValue: 'active',
allowNull: false,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
},
onDelete: 'CASCADE',
},
attendees: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: true,
},
calendar_source: {
type: DataTypes.ENUM('manual', 'google', 'microsoft', 'apple'),
defaultValue: 'manual',
},
external_id: {
type: DataTypes.STRING(255),
allowNull: true,
comment: 'External calendar event ID',
},
location: {
type: DataTypes.STRING(500),
allowNull: true,
},
meeting_url: {
type: DataTypes.STRING(500),
allowNull: true,
},
tags: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: true,
},
labels: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: true,
comment: 'Array of label IDs associated with this meeting',
},
is_recurring: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
recurrence_pattern: {
type: DataTypes.JSON,
allowNull: true,
comment: 'Stores recurrence rules for recurring meetings',
},
duration_minutes: {
type: DataTypes.INTEGER,
allowNull: true,
validate: {
min: 1,
max: 1440, // 24 hours max
},
},
}, {
tableName: 'meetings',
timestamps: true,
indexes: [
{
fields: ['user_id'],
},
{
fields: ['status'],
},
{
fields: ['start_time'],
},
{
fields: ['user_id', 'status'],
},
],
});
// Instance methods
Meeting.prototype.getDuration = function() {
if (this.end_time && this.start_time) {
return Math.floor((new Date(this.end_time) - new Date(this.start_time)) / (1000 * 60));
}
return this.duration_minutes || 0;
};
Meeting.prototype.isActive = function() {
return this.status === 'active';
};
Meeting.prototype.isCompleted = function() {
return this.status === 'completed';
};
Meeting.prototype.complete = async function() {
this.status = 'completed';
this.end_time = this.end_time || new Date();
return this.save();
};
// Class methods
Meeting.findActiveByUser = function(userId) {
return this.findAll({
where: {
user_id: userId,
status: 'active',
},
order: [['start_time', 'DESC']],
});
};
Meeting.findByUserAndDateRange = function(userId, startDate, endDate) {
return this.findAll({
where: {
user_id: userId,
start_time: {
[sequelize.Sequelize.Op.between]: [startDate, endDate],
},
},
order: [['start_time', 'ASC']],
});
};
Meeting.findRecentByUser = function(userId, limit = 10) {
return this.findAll({
where: {
user_id: userId,
},
order: [['start_time', 'DESC']],
limit,
});
};
module.exports = Meeting; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.2382 ]-- |