Built motion from commit 82438f7.|0.0.115
[motion.git] / server / models / history / report_openchannel_history.js
1 /**
2  * Agent Log Model
3  */
4
5 var moment = require('moment');
6
7 module.exports = function(sequelize, DataTypes) {
8
9   var ReportOpenchannelHistory = sequelize.define('ReportOpenchannelHistory', {
10     uniqueid: DataTypes.STRING,
11     timeslot: DataTypes.INTEGER,
12     accountid: DataTypes.STRING,
13     accountname: DataTypes.STRING,
14     application: DataTypes.STRING,
15     memberid: DataTypes.INTEGER,
16     membername: DataTypes.STRING,
17     queue: DataTypes.INTEGER,
18     queuename: DataTypes.STRING,
19     roomid: DataTypes.INTEGER,
20     messageid: DataTypes.INTEGER,
21     reason: {
22       type: DataTypes.STRING,
23       defaultValue: 'called'
24     },
25     connectid: {
26       type: DataTypes.STRING,
27       unique: true,
28       set: function() {
29         this.setDataValue('connectid', this.uniqueid);
30         this.setDataValue('reason', 'connect');
31         this.setDataValue('connectedAt', moment().format("YYYY-MM-DD HH:mm:ss"));
32       }
33     },
34     calledAt: DataTypes.DATE,
35     rejectedAt: DataTypes.DATE,
36     connectedAt: DataTypes.DATE
37   }, {
38     tableName: 'report_openchannel_history'
39   });
40   ReportOpenchannelHistory.removeAttribute('id');
41   return ReportOpenchannelHistory;
42 };