Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / voice_recording.js
index 736aa24..54bfb0a 100644 (file)
@@ -4,10 +4,18 @@ var moment = require('moment');
 module.exports = function(sequelize, DataTypes) {
   var VoiceRecording = sequelize.define('VoiceRecording', {
     uniqueid: {
-      type: DataTypes.STRING,
-      primaryKey: true
+      type: DataTypes.STRING
     },
     channel: {
+      type: DataTypes.STRING,
+      set: function(channel) {
+        if (channel) {
+          this.setDataValue('channel', channel);
+          this.setDataValue('membername', channel.split(/\/|-/)[1]);
+        }
+      }
+    },
+    membername: {
       type: DataTypes.STRING
     },
     calleridnum: {
@@ -42,24 +50,29 @@ module.exports = function(sequelize, DataTypes) {
     },
     rating: {
       type: DataTypes.INTEGER,
-      defaultValue: 0,
       validate: {
         max: 5,
         min: 0
       }
     },
+    queue: {
+      type: DataTypes.STRING
+    },
+    customerPhone: {
+      type: DataTypes.STRING
+    },
     createdAt: {
       type: DataTypes.DATE,
       get: function() {
         // 'this' allows you to access attributes of the instance
-        return moment(this.getDataValue('agentconnectAt')).format("MM-DD-YYYY HH:mm");
+        return moment(this.getDataValue('createdAt')).format("MM-DD-YYYY HH:mm").toString();
       }
     },
     updatedAt: {
       type: DataTypes.DATE,
       get: function() {
         // 'this' allows you to access attributes of the instance
-        return moment(this.getDataValue('agentconnectAt')).format("MM-DD-YYYY HH:mm");
+        return moment(this.getDataValue('updatedAt')).format("MM-DD-YYYY HH:mm").toString();
       }
     }
   }, {