Built motion from commit a0baffd.|1.0.1
[motion.git] / server / models / history / report_call_history.js
index 0e0b0f1..d90ba5a 100644 (file)
@@ -5,6 +5,16 @@
 module.exports = function(sequelize, DataTypes) {
 
   var ReportCallHistory = sequelize.define('ReportCallHistory', {
+    sourceid: DataTypes.INTEGER,
+    uniqueid: {
+      type: DataTypes.STRING,
+      unique: true
+    },
+    type: {
+      type: DataTypes.ENUM,
+      values: ['inbound', 'internal', 'outbound', 'inbound-fax', 'outbound-fax', 'tigerdial']
+    },
+    tag: DataTypes.STRING,
     accountcode: DataTypes.STRING,
     source: DataTypes.STRING,
     destination: DataTypes.STRING,
@@ -15,27 +25,32 @@ module.exports = function(sequelize, DataTypes) {
     lastapplication: DataTypes.STRING,
     lastdata: DataTypes.STRING,
     starttime: DataTypes.DATE,
-    answertime: {
-      type: DataTypes.DATE,
-      set: function(answertime) {
-        if (answertime !== '') {
-          this.setDataValue('answertime', answertime);
-        } else {
-          this.setDataValue('answertime', null);
-        }
-      }
-    },
+    answertime: DataTypes.DATE,
     endtime: DataTypes.DATE,
     duration: DataTypes.INTEGER,
     billableseconds: DataTypes.INTEGER,
     disposition: DataTypes.STRING,
     amaflags: DataTypes.STRING,
-    uniqueid: DataTypes.STRING,
-    userfield: DataTypes.STRING,
+    userfield: DataTypes.STRING
   }, {
-    tableName: 'report_call_history'
+    tableName: 'report_call_history',
+    indexes: [{
+      name: 'sourceid',
+      fields: ['sourceid']
+    }],
+    associate: function(models) {
+      // ReportCallHistory.hasMany(models.ReportQueueHistory, {
+      //   as: 'HistoryQueueCalls',
+      //   foreignKey: 'uniqueid',
+      //   constraints: false
+      // });
+      // ReportCallHistory.hasMany(models.ReportAgentHistory, {
+      //   as: 'HistoryReportAgents',
+      //   foreignKey: 'uniqueid',
+      //   constraints: false
+      // });
+    }
   });
-
   ReportCallHistory.removeAttribute('id');
   return ReportCallHistory;
 };