Ignore:
Timestamp:
06/14/12 18:00:45 (12 years ago)
Author:
eduardow
Message:

Ticket #2855 - Lentidão na abertura da Expresso Calendar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/prototype/modules/calendar/interceptors/DBMapping.php

    r6393 r6501  
    539539 
    540540                if (isset($v['id'])) { 
    541                     $result[$i]['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable'  ,  $v['id']),'deepness' => $original['criteria']['deepness'] - 1 ));  
    542  
     541                    $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original);  
     542         
     543                    $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false;  
     544                    $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false;  
     545                    $result[$i]['participants'] = $data['attendees'];  
     546         
    543547                    $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 
    544548                    if (is_array($attachmentRelation)) { 
     
    563567        return $result; 
    564568    } 
     569 
    565570 
    566571//TODO: Remover apos suporte a deepness na api 
     
    689694///////////////////////////////////////////////////////////////////////// 
    690695 
    691     static function dayAlarm( &$uri , &$params , &$criteria , $original ) {      
     696    static function decodeParticipantsEvent( &$uri, $result, &$criteria, $original) {  
     697        $participants = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable'  ,  $result['id']) ));  
     698                  
     699        if($participants && ($size = count($participants)) < 100){  
     700            if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0){  
     701               self::deepnessFindParticipant($uri, $participants, $criteria, $original);  
     702                $participants['attendees'] = $participants;  
     703            }  
     704                              
     705        }else if($participants && ($size = count($participants)) > 100){  
     706           $owner = Controller::read( array( 'concept' => 'calendarSignature' ) , false ,array( 'filter' => array('AND', array('=', 'calendar'  ,  $result['calendar']), array('=', 'isOwner', '1'))));  
     707           $owner = Controller::read( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable'  ,  $result['id']), array('=', 'user', $owner[0]['user'])), 'deepness' => 2));  
     708          
     709           if(is_array($owner))  
     710               $owner = $owner[0];  
     711          
     712           $reference = array_slice($participants, 0, 100);  
     713           $organizer = false;  
     714           $asOwner = false;  
     715                  
     716            foreach($reference as $r => &$v){  
     717                if($v['id'] == $owner['id']){  
     718                   $v = $owner;  
     719                   $asOwner = true;  
     720                   continue;  
     721                }  
     722                  
     723                self::deepnessReadParticipant($uri, $v, $criteria, $original);  
     724          
     725                if($v['isOrganizer'] == "1" )  
     726                   $organizer = $v;  
     727           }  
     728          
     729           if(!$organizer){  
     730               $organizer = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable'  ,  $result['id']), array('=', 'isOrganizer', '1')), 'deepness' => 2));  
     731                  
     732               array_push($reference, $organizer[0]);  
     733          
     734           }else if($organizer && ($organizer['id'] != $owner['id']))  
     735               array_merge($reference, $organizer);  
     736         
     737           if(!$asOwner)  
     738               array_push($reference, $owner);  
     739                  
     740           $statusAttendees = array( 'default' => 0, 'accepted' => 0, 'tentative' => 0, 'cancelled' => 0, 'unanswered' => 0, 'delegated' => 0 );  
     741           $statusLabels = array( 'default', 'accepted', 'tentative', 'cancelled', 'unanswered', 'delegated' );  
     742                  
     743           foreach($participants as $k => &$p){  
     744               if(!$organizer && $p['isOrganizer'] == "1"){  
     745                   self::deepnessReadParticipant($uri, $p, $criteria, $original);  
     746                   $reference = array_merge($reference, array($p));  
     747               }  
     748                  
     749               $statusAttendees[$statusLabels[$p['status']]]++;  
     750           }  
     751                  
     752           $participants['statusAttendees'] = $statusAttendees;  
     753           $participants['sizeAttendees'] = $size;  
     754           $participants['attendees'] = $reference;  
     755        }  
     756                          
     757        return $participants;  
     758    }  
     759              
     760    static function dayAlarm( &$uri , &$params , &$criteria , $original ) {     
    692761        if(isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') 
    693762        { 
     
    884953                //Criaremos uma agenda padrão 
    885954                $cal = array('name' => 'Calendario', 
    886                     'description' => 'Calendario Padrï¿œo', 
     955                  'description' => 'Calendario Padrão',  
    887956                    'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 
    888957                    'dtstamp' => time() . '000' 
Note: See TracChangeset for help on using the changeset viewer.