Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const AV = require('leancloud-storage')
const schedule = require('node-schedule')
const APP_ID = 'yzbpXQpXf1rWVRfAAM8Durgh-gzGzoHsz'
const APP_KEY = '020bjTvbiVinVQ21YtWAJ9t8'
AV.init({
appId: APP_ID,
appKey: APP_KEY
})
const Site = AV.Object.extend('Site')
let j = schedule.scheduleJob('* */4 * * *', calc); // every 4 hours
function calc() {
let counter = {}
let query = new AV.Query('Page')
query.each((page) => {
let d = page.get('domain')
if (counter[d]) counter[d] += page.get('count')
else counter[d] = page.get('count')
}).then(() => {
console.log('Collect all pages.')
for (let domain in counter) {
if (counter.hasOwnProperty(domain)) {
let siteView = counter[domain]
export function cerateTeam(payload, currentUser) {
const teams = new AV.Object('Teams')
for (let key of Object.keys(payload)) {
teams.set(key, payload[key])
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', currentUser)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(AV.User.currentAsync(), true)
userTeamMap.setACL(acl)
return userTeamMap.save().then(function(result) {
return result.get('team').toJSON()
})
}
export function cerateTeam(payload) {
const teams = new AV.Object('Teams')
for (let key of Object.keys(payload)) {
teams.set(key, payload[key])
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const user = getCurrentUser()
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', user)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(AV.User.current(), true)
userTeamMap.setACL(acl)
return userTeamMap.save().then(function(result) {
return result.get('team').toJSON()
})
}
export function cerateTeam(payload) {
const teams = new AV.Object('Teams')
for (let key of Object.keys(payload)) {
teams.set(key, payload[key])
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const user = getCurrentUser()
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', user)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
export function cerateTeam(payload, currentUser) {
const teams = new AV.Object('Teams')
for (let key of Object.keys(payload)) {
teams.set(key, payload[key])
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', currentUser)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
var acl = new AV.ACL()
const AV = require('leancloud-storage');
const config = require('../config');
AV.init({
'appId': config.leancloud.appId,
'appKey': config.leancloud.appKey
});
module.exports = {
'Object': AV.Object
}
userName = readlineSync.question('Enter your username: ');
passWord = readlineSync.question('Enter your password: ', { hideEchoBack: true });
} else if (!passWord) {
passWord = readlineSync.question('Enter your password: ', { hideEchoBack: true });
}
_context.next = 16;
return AV.User.logIn(userName, passWord).then(function (loginedUser) {
log.info('Logined as: ' + loginedUser.getUsername());
}, function (error) {
log.error(error);
});
case 16:
log.info('Now syncing your posts list to leancloud counter...');
Counter = AV.Object.extend('Counter');
urls.sort(cmp);
memoFile = pathFn.join(publicDir, "leancloud.memo");
if (!fs.existsSync(memoFile)) {
fs.writeFileSync(memoFile, "[\n]");
}
memoData = fs.readFileSync(memoFile, "utf-8").split("\n");
memoIdx = 1;
newData = [];
cnt = 0;
limit = 0;
env = this;
_.forEach(urls, function (x) {
var y = {};
resolve: (source, args, {authOptions}, info) => {
const saveOptions = _.extend({fetchWhenSave: true}, authOptions)
if (args.objectId) {
return AV.Object.createWithoutData(className, args.objectId).save(_.omit(args, 'objectId'), saveOptions);
} else {
return new classes[className]().save(args, saveOptions);
}
}
}
export function cerateResumeOrder(payload, userinfo) {
const user = getCurrentUser()
const resumeOrders = new AV.Object('ResumeOrders')
resumeOrders.set('title', payload.title)
resumeOrders.set('description', payload.description)
resumeOrders.set('contact', payload.contact)
const endDate = new Date(payload.endDate)
resumeOrders.set('endDate', endDate)
resumeOrders.set('user', user)
resumeOrders.set('stick', 0)
resumeOrders.set('show', 1)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(user, true)
resumeOrders.setACL(acl)
return resumeOrders.save().then(function(result) {
return { ...result.toJSON(), userinfo }
export function cerateWarOrder(payload, team, currentUser) {
const teamData = AV.Object.createWithoutData('Teams', payload.teamid)
const warOrders = new AV.Object('WarOrders')
warOrders.set('title', payload.title)
warOrders.set('description', payload.description)
warOrders.set('contact', payload.contact)
warOrders.set('stick', 0)
warOrders.set('show', 1)
const endDate = new Date(payload.endDate)
warOrders.set('endDate', endDate)
warOrders.set('user', currentUser)
warOrders.set('team', teamData)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(currentUser, true)
warOrders.setACL(acl)
return warOrders.save().then(function(result) {