Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. commit ef40f3f231539eddb8d033b8b3f328d1bb1c8c8f
  2. Author: Moe <github@m03.ca>
  3. Date: Sun Mar 24 18:36:35 2019 -0700
  4.  
  5. fix CE video bug
  6.  
  7. diff --git a/libs/sql.js b/libs/sql.js
  8. index 27b0639..6035280 100644
  9. --- a/libs/sql.js
  10. +++ b/libs/sql.js
  11. @@ -1,4 +1,3 @@
  12. -moment = require('moment')
  13. module.exports = function(s,config){
  14. s.onBeforeDatabaseLoadExtensions.forEach(function(extender){
  15. extender(config)
  16. @@ -8,9 +7,7 @@ module.exports = function(s,config){
  17. client: config.databaseType,
  18. connection: config.db,
  19. }
  20. - var isSqlite = false
  21. if(s.databaseOptions.client.indexOf('sqlite')>-1){
  22. - isSqlite = true
  23. s.databaseOptions.client = 'sqlite3';
  24. s.databaseOptions.useNullAsDefault = true;
  25. try{
  26. @@ -49,8 +46,12 @@ module.exports = function(s,config){
  27. }
  28. return newQuery
  29. }
  30. + s.getUnixDate = function(value){
  31. + newValue = new Date(value).valueOf()
  32. + return newValue
  33. + }
  34. s.stringToSqlTime = function(value){
  35. - newValue = new Date(s.nameToTime(value)).valueOf()
  36. + newValue = new Date(value.replace('T',' '))
  37. return newValue
  38. }
  39. s.sqlQuery = function(query,values,onMoveOn,hideLog){
  40. @@ -90,9 +91,6 @@ module.exports = function(s,config){
  41. }
  42. })
  43. }
  44. - s.openDatabaseTable = function(tableName){
  45. - return s.databaseEngine(tableName)
  46. - }
  47. s.connectDatabase = function(){
  48. s.databaseEngine = require('knex')(s.databaseOptions)
  49. }
  50. @@ -120,6 +118,13 @@ module.exports = function(s,config){
  51. s.sqlQuery("CREATE TABLE IF NOT EXISTS `Schedules` (`ke` varchar(50) DEFAULT NULL,`name` text,`details` text,`start` varchar(10) DEFAULT NULL,`end` varchar(10) DEFAULT NULL,`enabled` int(1) NOT NULL DEFAULT '1')" + mySQLtail + ';',[],function(err){
  52. if(err)console.error(err)
  53. },true)
  54. + //add Timelapses and Timelapse Frames tables, will remove in future
  55. + s.sqlQuery("CREATE TABLE IF NOT EXISTS `Timelapses` (`ke` varchar(50) NOT NULL,`mid` varchar(50) NOT NULL,`details` longtext,`date` date NOT NULL,`time` timestamp NOT NULL,`end` timestamp NOT NULL,`size` int(11)NOT NULL)" + mySQLtail + ';',[],function(err){
  56. + if(err)console.error(err)
  57. + },true)
  58. + s.sqlQuery("CREATE TABLE IF NOT EXISTS `Timelapse Frames` (`ke` varchar(50) NOT NULL,`mid` varchar(50) NOT NULL,`details` longtext,`filename` varchar(50) NOT NULL,`time` timestamp NULL DEFAULT NULL,`size` int(11) NOT NULL)" + mySQLtail + ';',[],function(err){
  59. + if(err)console.error(err)
  60. + },true)
  61. //add Cloud Videos table, will remove in future
  62. s.sqlQuery('CREATE TABLE IF NOT EXISTS `Cloud Videos` (`mid` varchar(50) NOT NULL,`ke` varchar(50) DEFAULT NULL,`href` text NOT NULL,`size` float DEFAULT NULL,`time` timestamp NULL DEFAULT NULL,`end` timestamp NULL DEFAULT NULL,`status` int(1) DEFAULT \'0\',`details` text)' + mySQLtail + ';',[],function(err){
  63. if(err)console.error(err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement