d2520d4e27e50c1b0e70451a34946b1ec066cfed
[motion2.git] / server / api / interval / interval.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xe42d=['rewrite','interval','string','then','all','ifTime','reduce','./interval.attributes','../../components/extensions/rewrite','exports','define','Interval','tools_intervals'];(function(_0x3e751a,_0x4804ae){var _0x1d5aa1=function(_0x51ec5a){while(--_0x51ec5a){_0x3e751a['push'](_0x3e751a['shift']());}};_0x1d5aa1(++_0x4804ae);}(_0xe42d,0x13f));var _0xde42=function(_0x5a8423,_0x9d598){_0x5a8423=_0x5a8423-0x0;var _0x4bb583=_0xe42d[_0x5a8423];return _0x4bb583;};'use strict';var attributes=require(_0xde42('0x0'));var extensions=require(_0xde42('0x1'));var iftime=require('../../utils/iftime')['iftime'];module[_0xde42('0x2')]=function(_0x3860db){return _0x3860db[_0xde42('0x3')](_0xde42('0x4'),attributes,{'tableName':_0xde42('0x5'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x28a787){extensions[_0xde42('0x6')](_0x3860db,_0x28a787);},'afterBulkCreate':function(_0x57fdfb,_0xd56e1d,_0x23ea2b){_0x23ea2b();extensions['rewrite'](_0x3860db,_0x57fdfb[0x0]);},'afterUpdate':function(_0x5ba317){extensions[_0xde42('0x6')](_0x3860db,_0x5ba317);},'afterDestroy':function(_0x3c958d){extensions[_0xde42('0x6')](_0x3860db,_0x3c958d);}},'instanceMethods':{'ifTime':function(_0x64d7c5=undefined,_0xbf1bf8=new Date()){if(typeof this[_0xde42('0x7')]===_0xde42('0x8')){return iftime(this['interval'],_0x64d7c5,_0xbf1bf8);}else{return this['getIntervals']()[_0xde42('0x9')](function(_0x20627f){return Promise[_0xde42('0xa')](_0x20627f['map'](function(_0x2f7b3d){return _0x2f7b3d[_0xde42('0xb')](_0x64d7c5,_0xbf1bf8);}));})['then'](function(_0x5eff1b){return _0x5eff1b[_0xde42('0xc')](function(_0x453545,_0x4a4e01){return _0x453545||_0x4a4e01;},![]);});}}}});};