mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* File Name: pending_certificate.mdl.js
|
|
* Type of Program: Model
|
|
* Description: Holds certificates queued for issuance after a 45-minute delay
|
|
* following a passed course assessment. The cron job
|
|
* (cron/jobs/issue_certificates.cron.js) polls this table every
|
|
* 5 minutes and processes rows where issue_at <= NOW().
|
|
*
|
|
* Author: Kenneth Obsequio (@lash0000)
|
|
* Date Created: Jun. 24, 2026
|
|
***********************************************************************************************************************************************************************/
|
|
const { DataTypes } = require('sequelize');
|
|
const sequelize = require('../../config/db.config');
|
|
|
|
const PendingCertificate = sequelize.define('PendingCertificate', {
|
|
pending_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
|
|
user_id: { type: DataTypes.BIGINT, allowNull: false },
|
|
course_id: { type: DataTypes.BIGINT, allowNull: false },
|
|
course_uuid: { type: DataTypes.STRING(36), allowNull: false },
|
|
course_title: { type: DataTypes.TEXT, allowNull: true },
|
|
passed_at: { type: DataTypes.DATE, allowNull: false },
|
|
issue_at: { type: DataTypes.DATE, allowNull: false },
|
|
processed_at: { type: DataTypes.DATE, allowNull: true },
|
|
}, {
|
|
tableName: 'pending_certificates',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['user_id'] },
|
|
{ fields: ['issue_at'] },
|
|
{ unique: true, fields: ['user_id', 'course_id'] },
|
|
],
|
|
});
|
|
|
|
module.exports = PendingCertificate;
|