Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/config/functions/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
const redis = require("redis");
const { stringEquals } = require("strapi-utils/lib");
const client = redis.createClient();
const bluebird = require("bluebird");
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);
module.exports = {
/**
* Simple example.
* Every monday at 1am.
*/
// '0 1 * * 1': () => {
//
// }
'*/60 * * * * *': async() => {
// client.flushdb( function (err, succeeded) {
// console.log(succeeded); // will be true if successfull
// });
// async function getLastHit() {
// return new Promise((res, rej) => {
// client.hgetall("last_hit", function (err, object) {
// // console.log(object);
// res(object.last_hit);
// });
// });
// }
// var last_hit_time=await getLastHit();
// // console.log(last_hit_time);
// var tim=new Date();
// let e_dt= new Date();
// e_dt.setSeconds( e_dt.getSeconds() + 2 );
// tim.setSeconds( tim.getSeconds() -2 );
// client.hmset("feeling", {current:tim,next:e_dt.toISOString()});
// async function getnextCron() {
// return new Promise((res, rej) => {
// client.hgetall("feeling", function (err, object) {
// // console.log(object);
// res(object.current);
// });
// });
// }
// var next_cron_time= await getnextCron();
// // console.log(next_cron_time);
// if(last_hit_time <= e_dt.toISOString() && last_hit_time >= tim.toISOString())
// {
// console.log("asche");
// // var user =await strapi.query('user', 'users-permissions').find();
// }
// else{
// console.log("hoi ni");
// }
// await client.hgetallAsync("feeling").then(function(object) {
// console.log(object);
// });
// client.hgetall("count", function (err, object) {
// console.log(object.count);
// });
// client.flushdb( function (err, succeeded) {
// console.log(succeeded); // will be true if successfull
// });
// client.del("count", function(err, reply) {
// console.log(reply);
// });
var user =await strapi.query('user', 'users-permissions').find();
user.forEach(users=>{
var header=users.token;
client.exists(header, function(err, reply) {
if (reply === 1) {
// client.del(header, function(err, reply) {
// console.log(reply);
// });
client.hgetall(header, function (err, object) {
// console.log(object); // user full information
if(parseInt(object.m_balance,10)!==parseInt(users.balance,10))
{
console.log("if");
var bal = users.balance-parseInt(object.m_balance,10);
var r_balance=parseInt(object.r_balance,10)+bal;
client.hmset(header, {m_balance:r_balance,r_balance:r_balance});
strapi.query('user', 'users-permissions').update({token: header}, {balance:r_balance});
client.flushdb( function (err, succeeded) {
console.log(succeeded); // will be true if successfull
});
}
else{
console.log(object.r_balance);
client.hmset(header, {m_balance:object.r_balance});
strapi.query('user', 'users-permissions').update({token: header}, {balance:object.r_balance});
client.flushdb( function (err, succeeded) {
console.log(succeeded); // will be true if successfull
});
}
// console.log(object.m_balance);
// console.log(users.balance);
});
}
});
}
)
},
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |