Built motion from commit 95b01fa.|0.0.70
[motion.git] / server / models / history / report_chat_history.js
1 /**
2  * Agent Log Model
3  */
4
5 var moment = require('moment');
6
7 module.exports = function(sequelize, DataTypes) {
8
9   var ReportChatHistory = sequelize.define('ReportChatHistory', {
10
11     uniqueid: DataTypes.STRING,
12     timeslot: DataTypes.INTEGER,
13     websitename: DataTypes.STRING,
14     websiteaddress: DataTypes.STRING,
15     websiteid: DataTypes.INTEGER,
16     application: DataTypes.STRING,
17     agentid: DataTypes.INTEGER,
18     agentname: DataTypes.STRING,
19     visitorid: DataTypes.STRING,
20     visitorname: DataTypes.STRING,
21     visitoremail: DataTypes.STRING,
22     queueid: DataTypes.INTEGER,
23     queuename: DataTypes.STRING,
24     roomid: DataTypes.INTEGER,
25     reason: {
26       type: DataTypes.STRING,
27       defaultValue: 'called'
28     },
29     connectid: {
30       type: DataTypes.STRING,
31       unique: true,
32       set: function(agentconnectedAt) {
33         this.setDataValue('connectid', this.uniqueid);
34         this.setDataValue('reason', 'connect');
35         this.setDataValue('connectedAt', moment().format("YYYY-MM-DD HH:mm:ss"));
36       }
37     },
38     calledAt: DataTypes.DATE,
39     connectedAt: DataTypes.DATE
40   }, {
41     tableName: 'report_chat_history'
42   });
43
44   return ReportChatHistory;
45 };