Plugin Directory

Changeset 1586858


Ignore:
Timestamp:
02/02/2017 12:01:01 AM (9 years ago)
Author:
pushpress
Message:

Reworked caching strategies

Location:
pushpress-integration/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pushpress-integration/trunk/inc/wp_pushpress_model.php

    r1580671 r1586858  
    88
    99    public function get_client() {
     10        $client = Pushpress_Client::retrieve('self');
     11        /*
    1012        if( !$client = get_transient( 'pp_client2' ) ){
    1113            $client = Pushpress_Client::retrieve('self');
    1214            set_transient( 'pp_client2', $client, 3600 ); // 1 hour cache                                                   
    13         }   
     15        }
     16        */ 
    1417        return $client;       
    1518    }
     
    1720    public function get_products() {
    1821
     22        $params = array(
     23            'active' => 1,
     24            'show_on_wp' => 1
     25        );
     26        //get products object
     27        $productsObj = Pushpress_Product::all($params);
     28
     29        /*
    1930        $key = "pp_client_active_products";
    2031        if (! $productsObj = get_transient($key)) {
     
    2738
    2839            set_transient( $key, $productsObj, 300 ); // 5m                       
    29         }
    30        
     40        }       
     41        */
    3142
    3243        $productsList = array();
     
    5465
    5566
    56 
     67        //get preorder
     68        $livePreorders = Pushpress_Preorder::all(array(
     69                    "closed" => 0, "completed" => 0, "cancelled" => 0
     70        ));
     71
     72        /*
    5773        if (! $livePreorders = get_transient("pp_client_active_preorders")) {
    5874            //get preorder
     
    6278            set_transient( 'pp_client_active_preorders', $livePreorders, 600 ); // 5m                       
    6379        }
     80        */
    6481        /*
    6582           
     
    100117        $key  = "pp_client_active_product_" . $id;
    101118
     119        try {
     120            $product = Pushpress_Product::retrieve($id);
     121        }
     122        catch (Exception $e) {
     123            return array();
     124        }
     125
     126        $productsList[$product->category->uuid]['products'][$product->uuid]['slug'] = $product->slug;
     127        $productsList[$product->category->uuid]['products'][$product->uuid]['name'] = $product->name;
     128        $productsList[$product->category->uuid]['products'][$product->uuid]['description'] = $product->description;
     129        $prices = array();
     130        $options = $product->options;
     131        foreach ($options as $option) {
     132            $prices[] = $option->price;
     133        }
     134        sort($prices);
     135        $productsList[$product->category->uuid]['products'][$product->uuid]['price'] = $prices;       
     136
     137        /*
    102138        if (! $product = get_transient($key)) {
    103139           
     
    117153            $productsList[$product->category->uuid]['products'][$product->uuid]['price'] = $prices;
    118154        }
     155        */
    119156
    120157        return $productsList;
     
    126163        $productsList = array();
    127164       
     165        $params = array(
     166            'active' => 1
     167        );
     168        //get products object
     169        $productsObj = Pushpress_Product::all($params);
     170
     171        /*
    128172        $key  = "pp_client_active_products_" . $category;
    129173
     
    136180            set_transient( $key, $productsObj, 300 ); // 5m
    137181        }
    138 
     182        */
    139183
    140184        foreach ($productsObj->data as $product) {
     
    166210        $plansList = array();
    167211
     212        $params = array(
     213            'active' => 1,
     214            'public' => 1,
     215            'type' => 'P,N,R'
     216        );
     217        //get all products object
     218        $plans = Pushpress_Plan::all($params);
     219
     220        /*
    168221        if (!$plans = get_transient("pp_client_active_plans_pnr")) {
    169222            $params = array(
     
    175228            $plans = Pushpress_Plan::all($params);
    176229            set_transient("pp_client_active_plans_pnr", $plans, 600);
    177         }       
     230        }
     231        */       
    178232       
    179233        $planType = array('R' => 'Recurring', 'N' => 'Non-Recurring', 'P' => 'Punchcards');
     
    203257            }
    204258        } catch (Exception $e) {
    205             return;
     259            return array();
    206260        }
    207261        return $plansList;
     
    211265        $plansList = array();
    212266       
     267        $params = array(
     268            'active' => 1,
     269            'public' => 1,               
     270        );
     271        //get all products object
     272        $plans = Pushpress_Plan::all($params);
     273
     274        /*
    213275        $key = "pp_client_plans_for_help";
    214276
     
    221283            $plans = Pushpress_Plan::all($params);
    222284            set_transient($key, $plans, 600);
    223         }       
     285        }
     286        */       
    224287       
    225288        foreach ($plans->data as $plan) {
     
    233296        $categories = array();
    234297       
     298        $params = array(
     299            'active' => 1
     300        );
     301        //get all products object
     302        $items = Pushpress_ProductCategories::all($params);
     303
     304        /*
    235305        $key = "pp_client_product_categories_for_help";
    236306
     
    243313            set_transient($key, $items, 600);
    244314        }
     315        */
    245316        foreach ($items->data as $item) {
    246317            $categories[$item->uuid] = mb_convert_encoding($item->name, 'UTF-8', 'HTML-ENTITIES');
     
    261332        $end = strtotime("today 00:00:00 +1 year"); // 1 year later
    262333
     334        $calendar = Pushpress_Calendar::all(array(
     335                        'active' => 1,
     336                        'type' => $isEvent,
     337                        'start_time' => $start,
     338                        'end_time' => $end
     339            ));
     340
     341        /*
    263342        $cache_key = "pp_client_calendar_" . $isEvent . "_" . $start . "_" . $end;
    264343       
     
    273352            set_transient($cache_key, $calendar, 600);
    274353        }
     354        */
    275355        $eventsList = array();
    276356   
     
    300380            }
    301381        } catch (Exception $e) {
    302             return;
     382            return array();
    303383        }
    304384        return $eventsList;
     
    353433            $cache_key = "pp_client_schedule_2" . $doy . "_" . $year . "_class";
    354434           
     435            $calendar = Pushpress_Calendar::all(array(
     436                            'active' => 1,
     437                            'doy' => $doy,
     438                            'year' => $year,
     439                            'type' => 'Class',
     440                ));
     441            /*
    355442            if (! $calendar = get_transient($cache_key)){
    356443                $calendar = Pushpress_Calendar::all(array(
     
    362449                set_transient($cache_key, $calendar, 600);
    363450            }
     451            */
    364452       
    365453            foreach ($calendar->data as $item) {
     
    412500            );
    413501
    414             if (!$tracks = get_transient("pp_client_tracks")) {
     502            // if (!$tracks = get_transient("pp_client_tracks")) {
    415503                $tracks = Pushpress_Track::all();
    416                 set_transient("pp_client_tracks", $tracks, 600);
    417             }
    418 
     504               // set_transient("pp_client_tracks", $tracks, 600);
     505            // }
     506
     507            //var_dump($tracks);
    419508
    420509            $results = array();
     
    433522                    $params['track_id'] = $track->uuid;
    434523
     524                    $workouts = Pushpress_Track_Workout::all($params);
     525                    /*
    435526                    if (!$workouts = get_transient("pp_track_workouts_" . $track->uuid)) {
    436527                        $workouts = Pushpress_Track_Workout::all($params);
    437528                        set_transient("pp_track_workouts_" . $track->uuid, $workouts, 600);
    438529                    }
     530                    */
    439531
    440532                    $results[$key]['workouts'] = $this->filter_data_by_date($workouts, $timeNow, $client, $public_setting);
     
    487579            $client = $this->get_client();
    488580            // get integration settings
     581            $integration_settings = Pushpress_Client::settings('lead_capture');
     582            /*
    489583            if (!$integration_settings = get_transient("pp_settings_lead_capture")) {
    490584                $integration_settings = Pushpress_Client::settings('lead_capture');
    491585                set_transient("pp_settings_lead_capture", $integration_settings, 300); // 5m
    492586            }
     587            */
    493588           
    494589            foreach ($integration_settings as $item) {
     
    496591            }
    497592
     593            $referral_sources = Pushpress_Client::referralSources();
     594            /*
    498595            if (!$referral_sources = get_transient("pp_settings_referral_sources")) {
    499596                $referral_sources = Pushpress_Client::referralSources();
    500597                set_transient("pp_settings_referral_sources", $referral_sources, 3600); // 1 hour
    501             }           
     598            }
     599            */           
    502600
    503601            foreach ($referral_sources->data as $item) {
     
    730828
    731829    public function facebook_integrations() {
    732 
     830        try {
     831            $integration_settings = Pushpress_Client::settings('integration');
     832        }
     833        catch (Exception $e) {
     834            $integration_settings = array();
     835        }
     836        /*
    733837        if( !$integration_settings = get_transient( 'pp_client_settings_integration' ) ){
    734838            try {
     
    740844            set_transient( 'pp_client_settings_integration', $integration_settings, 600 ); // 10 minute cache
    741845        }
     846        */
    742847
    743848       
     
    764869    public function facebook_metrics() {
    765870
     871        try {
     872            $settingsObj = Pushpress_Client::settings('metrics');               
     873        }
     874        catch (Exception $e) {
     875            $settingsObj = array();
     876        }
     877
     878        /*
    766879        if( !$settingsObj = get_transient( 'pp_client_settings_metrics' ) ){
    767880            try {
     
    773886            set_transient( 'pp_client_settings_metrics', $settingsObj, 60 ); // 1 minute cache
    774887        }
     888        */
    775889
    776890        $metrics = array();
  • pushpress-integration/trunk/pushpress.php

    r1580681 r1586858  
    22/**
    33 * @package WP-PushPress
    4  * @version 1.5.13
     4 * @version 1.5.14
    55 */
    66/*
     
    99Description: Easily integrate your workouts, calendar, products, membership plans, events and more with your Wordpress blog!  This plugin is a free add-on for existing PushPress clients.  See https://pushpress.com for more info.
    1010Author: PushPress, Inc
    11 Version: 1.5.13
     11Version: 1.5.14
    1212Author URI: https://pushpress.com
    1313*/
    1414define('PUSHPRESS_LOCAL', FALSE);
    1515define('PUSHPRESS_DEV', FALSE);
    16 define( 'PP_PLUGIN_VERSION', '1.5.13');
     16define( 'PP_PLUGIN_VERSION', '1.5.14');
    1717define( 'PUSHPRESS_ERROR_REPORT', 0 );
    1818define( 'PUSHPRESS_BUTTON_CLASS',  'pushpress-button-class-' . rand(0, 10000));
  • pushpress-integration/trunk/readme.txt

    r1580681 r1586858  
    44Requires at least: 3.0.1
    55Tested up to: 4.6.1
    6 Stable tag: 1.5.13
     6Stable tag: 1.5.14
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    129129= 1.5.12 =
    130130Found an issue causing the workout page to not display workouts in some cases.
     131
     132= 1.5.14 =
     133Updating caching strategies.
Note: See TracChangeset for help on using the changeset viewer.