Xuups
Get an account!     Login

Utilities

Main menu

Who's Online

11 user(s) are online (3 user(s) are browsing Forum)

Members: 0
Guests: 11

more...

Get Xoops

Support Xuups Project


Browsing this Thread:   1 Anonymous Users





update points problems
Just popping in
Joined:
2009/11/22 12:48
Group:
Registered Users
Posts: 4
Offline
Hello,

I have a problem with the auto update.

I set 36000 secs in the refresh time field in module admin, but every time i visit the points page the points automatically auto update. This is for me 23300 querys to database.

I check the code and dont understand this

function mypoints_updatePoints($force 0)
{
    global 
$xoopsDB$xoopsModuleConfig;

    
$module_handler   xoops_gethandler('module');
    
$plugin_handler   xoops_getmodulehandler('plugin');
    
$user_handler     xoops_getmodulehandler('user');
    
$relation_handler xoops_getmodulehandler('relation');

    
$refreshtime $xoopsModuleConfig['refreshtime'];
    
$since strtotime($xoopsModuleConfig['countsince']);
    
$countwebm $xoopsModuleConfig['countadmin'];

    
$user $user_handler->get(0);
    
$timestamp 0;
    if (
is_object($user)) {
        
$timestamp $user->getVar('useruname');
    }

    if (((
time() - $timestamp) >= $refreshtime) || $force == 1) {
        
// Timer expired, update table
        // Set date of update
        
$user_handler->deleteAll();
        
$relation_handler->deleteAll();

        
$user $user_handler->create();
        
$user->setVar('useruid'0);
        
$user->setVar('useruname'time());
        
$user->setVar('userpoints'0);
        
$user_handler->insert($user);


I dont understand how the last update time is stored in db.. I mean, the username vble in the db is for store the user name... ¿¿?


Posted on: 2009/11/22 13:08
Transfer the post to other applications Transfer


Re: update points problems
Moderator
Joined:
2008/4/7 0:30
From Portugal
Group:
Webmasters
Registered Users
Posts: 303
Offline
well, yeah, useruid=0 is a fake user that holds last update.

What version of mypoints are you using?

Posted on: 2009/11/23 13:30

Edited by trabis on 2009/11/23 14:09:13
_________________
TDM
Transfer the post to other applications Transfer


Re: update points problems
Just popping in
Joined:
2009/11/22 12:48
Group:
Registered Users
Posts: 4
Offline
$modversion['name'] = _MI_MYPOINTS_NAME;
$modversion['version'] = "1.00";

Ok, now I understand :D

The problem is that the user 0 update allright with the time, but doenst matter what time for update i set on th admin side (tried 36000 and 3600secs), all visits to mypoint module index results on 23000 queries to database (a points update).

I check the code again and understand that this expression
if (((time() - $timestamp) >= $refreshtime) || $force == 1)


is alway true..

could be that timestamp is always 0?
$timestamp 0;
    if (
is_object($user)) {
        
$timestamp $user->getVar('useruname');
    }


Any idea or test you want me to do? :D

Thks

Posted on: 2009/11/24 13:59
Transfer the post to other applications Transfer


Re: update points problems
Moderator
Joined:
2008/4/7 0:30
From Portugal
Group:
Webmasters
Registered Users
Posts: 303
Offline
Hi, seems like core does not accept getting a field with id of 0 (this is core bug).

Please edit class/user.php and change this class:
class MypointsUserHandler extends XoopsPersistableObjectHandler
{
    
/**
     * constructor
     */
    
function __construct(&$db)
    {
        
parent::__construct($db"mypoints_user"'MypointsUser'"useruid""useruname");
    }
    
    
/**
     * Load a [email protected] XoopsObject} object from the database
     *
     * @access protected
     * @param mixed $id ID
     * @param array $fields fields to fetch
     * @return object [email protected] XoopsObject}
     */
    
function &get($id null$fields null)
    {
        
$object null;
        if (!isset(
$id)) {
            
$object $this->create();
            return 
$object;
        }
        if (
is_array($fields) && count($fields) > 0) {
            
$select implode(','$fields);
            if (!
in_array($this->keyName$fields)) {
                
$select .= ', ' $this->keyName;
            }
        } else {
            
$select '*';
        }
        
$sql sprintf('SELECT %s FROM %s WHERE %s = %s'$select$this->table$this->keyName$this->db->quote($id));
        
//$sql = "SELECT {$select} FROM {$this->table} WHERE {$this->keyName} = " . $this->db->quote($id);
        
if (!$result $this->db->query($sql)) {
            return 
$object;
        }
        if (!
$this->db->getRowsNum($result)) {
            return 
$object;
        }
        
$object =& $this->create(false);
        
$object->assignVars($this->db->fetchArray($result));

        return 
$object;
    }

}


Thanks, I will update module soon.

Posted on: 2009/11/24 18:56
_________________
TDM
Transfer the post to other applications Transfer


Re: update points problems
Just popping in
Joined:
2009/11/22 12:48
Group:
Registered Users
Posts: 4
Offline
Hi, it works.. thks

Posted on: 2009/11/24 21:34
Transfer the post to other applications Transfer


Re: update points problems
Just popping in
Joined:
2015/3/30 10:12
From faisalabad
Group:
Registered Users
Posts: 1
Offline
Feb 20, 2015 - Troubleshooting issues with iTunes for Windows updates. turingtest2. By turingtest2. Level 9 (54,475 points). Version 161. 52272 Views.







______________________________________________________

Get free demos for testking exam and mcts exam with guaranteed success. Our best quality prepares you well before appearing in the final exams of rasmussen &mcts www.loyola.edu

Posted on: 2015/3/30 10:13

Edited by jangoolee on 2015/4/16 16:40:12
Edited by jangoolee on 2015/4/16 16:41:00
Edited by jangoolee on 2015/4/16 16:41:53
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


 

Login

Username:

Password:

Remember me



Lost Password?

Register now!

Ajax Search


Advanced Search

Newest Posts