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