You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/**
* @class Version 应用版本模型
*/
const BaseMod = require ( './base' )
const {
DateTime
} = require ( '../lib' )
module . exports = class Setting extends BaseMod {
constructor ( ) {
super ( )
this . tableName = 'opendb-tempdata'
this . tablePrefix = false
this . settingKey = "uni-stat-setting"
}
/**
* 获取统计云端配置
*/
async getSetting ( ) {
const res = await this . getCollection ( this . tableName ) . doc ( this . settingKey ) . get ( ) ;
if ( res . data && res . data [ 0 ] && res . data [ 0 ] . value ) {
return res . data [ 0 ] . value ;
} else {
return {
mode : "open" ,
day : 7
} ;
}
}
/**
* 检测N天内是否有设备访问记录, 如果有, 则返回true, 否则返回false
*/
async checkAutoRun ( obj = { } ) {
let {
day = 7
} = obj ;
const _ = this . dbCmd ;
let nowTime = Date . now ( ) ;
const res = await this . getCollection ( "uni-stat-session-logs" ) . where ( {
create _time : _ . gte ( nowTime - 1000 * 3600 * 24 * day )
} ) . count ( ) ;
return res . total > 0 ? true : false ;
}
}