Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2016, 12:39 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 117,104
Abronsyth is on a distinguished road
Default Optimizing Profiles and Daycare

Hello!

I've noticed that the daycare and user profiles (anywhere where a large amount of pets must be loaded) seems to load extremely slowly on my site. The host itself may be to blame, but it's difficult for me to tell in that regard.

Does anyone possible have some ideas to optimize these features so that they load more quickly? Right now I have the daycare modified to only show 25 pets, and then needs to be reloaded to show more (so no pages), and profiles display pet groups (so not all at once).
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #2  
Old 03-25-2016, 08:33 PM
RestlessThoughts's Avatar
RestlessThoughts RestlessThoughts is offline
Member
 
Join Date: Mar 2016
Posts: 10
Gender: Female
Credits: 1,133
RestlessThoughts is on a distinguished road
Default

Well, I have a couple suggestions that may or may not help much.
Probably the easiest way to potentially speed up the pages may be to add suitable indexes to your mysql tables. You can do that from phpmyadmin, going to structure then clicking to add an index on the column.

My index suggestions would be to add an index on the columns in the following tables:
owned_adoptables table - owner, type, possibly currentlevel
adoptables table - type
levels table - adoptiename, thisislevel

These are the columns that the daycare uses to select pet information. If your tables are small, indexes won't help. Also, indexes can slow inserts so don't add too many.

You should also optimize your images as much as you can.

I also wrote a few new functions for the daycare. The daycare code calls the database multiple times per pet displayed, so I used joins to combine the individual calls into one big call for the whole result set. This mostly helps avoid latency. The custom functions also bypass some of the classes since many of the constructors call the database and for ease of use I didn't want to modify more than two files. Also didn't want to directly replace methods, so the result is slight code duplication but this way it can't interfere with anything else on the site.

Anyway, add these three methods to the bottom of your class_daycare.php file, under the getStats method.
PHP Code:
    public function joinedListing() {
        
$mysidia Registry::get('mysidia');
        
$conditions $this->getConditions();
        
$fetchMode $this->getFetchMode($conditions);
        
$stmt $mysidia->db->join('adoptables','owned_adoptables.type = adoptables.type')->join('levels''owned_adoptables.type = levels.adoptiename')->select("owned_adoptables", array(), $conditions.' and '.PREFIX.'owned_adoptables.currentlevel = '.PREFIX.'levels.thisislevel'.$fetchMode);
        
$this->total $stmt->rowCount();
        if(
$this->total == 0) throw new DaycareException("empty");
        
$adopts $stmt->fetchAll(PDO::FETCH_ASSOC);
        
$this->adopts Arrays::fromArray($adopts);
        return 
$this->adopts;
    }

    public function 
getStatsFromArray($adopt) {
        
$stats null;
        foreach(
$this->settings->info as $info)
        {
            
$stats .= $info.': '.$adopt[strtolower($info)].'<br>';
        }
        return 
$stats;
    }

    public function 
getImageFromArray($adopt) {
        if (
$adopt['currentlevel'] == 0) return $adopt['eggimage'];
        if (
$adopt['usealternates'] == 'yes') return $adopt['alternateimage'];
        if (
$adopt['imageurl'] != null) return $adopt['imageurl'];
        return 
$adopt['primaryimage'];
    } 
And assuming you haven't modified the file, replace your levelupview.php daycare method with this one. The code commented out is the original code.
PHP Code:
    public function daycare(){
    
//    $mysidia = Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($this->lang->daycare_title);
        
$document->addLangvar($this->lang->daycareTRUE);

        
$daycare $this->getField("daycare");
    
//    $adopts = $daycare->getAdopts();
        
$daycareTable = new Table("daycare"""FALSE);
        
$daycareTable->setBordered(FALSE);

        
// New method call
        
$adopts $daycare->joinedListing();

        
$total $daycare->getTotalAdopts();
        
$index 0;

        for(
$row 0$row $daycare->getTotalRows(); $row++){
            
$daycareRow = new TRow("row{$row}");
            for(
$column 0$column $daycare->getTotalColumns(); $column++){
            
//  $adopt = new OwnedAdoptable($adopts[$index]);

                
$adopt $adopts[$index];
                
$cell = new ArrayList;
            
//    $cell->add(new Link("levelup/click/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE));
            //    $cell->add(new Comment($daycare->getStats($adopt)));

                // New display calls.
                
$cell->add(new Link("levelup/click/{$adopt['aid']}""<img src='{$daycare->getImageFromArray($adopt)}'>"TRUE));
                
$cell->add(new Comment($daycare->getStatsFromArray($adopt)));

                
$daycareCell = new TCell($cell"cell{$index}");
                
$daycareCell->setAlign(new Align("center""center"));
                
$daycareRow->add($daycareCell);
                
$index++;
                if(
$index == $total) break;
            }
            
$daycareTable->add($daycareRow);
        }

        
$document->add($daycareTable);
        if(
$pagination $daycare->getPagination()) $document->addLangvar($pagination->showPage());
    } 
Let me know if these suggestions help any, or if you run into trouble implementing them.
Reply With Quote
  #3  
Old 03-26-2016, 01:41 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 117,104
Abronsyth is on a distinguished road
Default

Well, the daycare loading speed is vastly improved! Absolutely brilliant, thank you so very much! Damned thing was driving me crazy!

I'm still looking over the profiles and seeing what I can do there, haha.
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:25 AM.

Currently Active Users: 846 (0 members and 846 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636