Ignore:
Timestamp:
12/31/12 10:57:51 (7 years ago)
Author:
cristiano
Message:

Ticket #3260 - Requisição de alarmes de eventos custosa quando existem muitos eventos

File:
1 edited

Legend:

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

    r7680 r7696  
    11301130        if(isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') 
    11311131        { 
    1132             $target = $criteria['filter'][2]; 
    1133  
    1134             $params = array(); 
    1135  
    1136             $al = Controller::service('PostgreSQL')->execSql("SELECT distinct co.id as \"id\", co.cal_uid as \"uid\", co.type_id as \"type\", co.dtstart as \"startTime\", co.summary as \"summary\", co.description as \"description\", co.dtend as \"endTime\", co.location as \"location\", co.allday as \"allDay\", co.transp as transparent, co.class_id as class, ". 
    1137                 "co.range_start as \"rangeStart\", co.range_end as \"rangeEnd\", co.last_update as \"lastUpdate\", co.dtstamp as \"dtstamp\", co.sequence as \"sequence\", co.tzid as \"timezone\", CASE WHEN rep.object_id = co.id THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END as \"sendTime\", ". 
    1138                 "al.unit as \"unit\", al.time as \"time\" FROM calendar_alarm as al, calendar_object as co, calendar_repeat as rep, calendar_repeat_occurrence as occ, calendar_participant as part WHERE ". 
    1139                 "al.action_id = '".ALARM_ALERT."' AND al.sent = '0' AND ( (al.participant_id = part.id) AND (part.user_info_id = '". Config::me('uidNumber') ."') ) AND part.object_id = co.id AND ". 
    1140                 "CASE WHEN rep.object_id = co.id ". 
    1141                 "THEN rep.id = occ.repeat_id AND occ.occurrence - al.alarm_offset >= '$target' AND occ.occurrence - al.alarm_offset <= '".( $target + 86400000)."' ". 
    1142                 "ELSE (co.range_start - al.alarm_offset) >= '$target' AND (co.range_start - al.alarm_offset) <= '".( $target + 86400000)."' END"); 
    1143  
    1144             if(is_array($al)) 
    1145               foreach( $al as $v ) 
    1146                 $params[] = array('schedulable' =>  $v); 
    1147  
    1148             else 
    1149               $params = false; 
    1150  
    1151             return false; 
     1132            $start = $criteria['filter'][2]; 
     1133            $end =  $start + 86400000; 
     1134            $params = array(); 
     1135 
     1136            $select = "SELECT co.id as \"id\", co.cal_uid as \"uid\", co.type_id as \"type\", co.dtstart as \"startTime\", co.summary as \"summary\", co.description as \"description\",co.dtend as \"endTime\", co.location as \"location\", co.allday as \"allDay\", co.transp as transparent, co.class_id as class, co.range_start as \"rangeStart\", co.range_end as \"rangeEnd\", co.last_update as \"lastUpdate\", co.dtstamp as \"dtstamp\", co.sequence as \"sequence\", co.tzid as \"timezone\", CASE WHEN occ.occurrence > 0 THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END as \"sendTime\", al.unit as \"unit\",al.time as \"time\" FROM calendar_object as co INNER JOIN calendar_alarm al ON co.id = al.object_id JOIN calendar_participant part  ON part.id = al.participant_id LEFT JOIN calendar_repeat rep ON  rep.object_id = co.id LEFT JOIN calendar_repeat_occurrence occ ON occ.repeat_id = rep.id  WHERE part.user_info_id = '".Config::me('uidNumber')."' AND al.action_id = '".ALARM_ALERT."' AND al.sent = '0' AND CASE WHEN occ.occurrence > 0 THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END BETWEEN $start AND $end "; 
     1137 
     1138            $al = Controller::service('PostgreSQL')->execSql($select); 
     1139 
     1140 
     1141            if(is_array($al)) 
     1142              foreach( $al as $v ) 
     1143                  $params[] = array('schedulable' =>  $v); 
     1144            else 
     1145              $params = false; 
     1146 
     1147                return false; 
    11521148        } 
    11531149    }  
Note: See TracChangeset for help on using the changeset viewer.