Making WordPress.org

Changeset 2024


Ignore:
Timestamp:
11/01/2015 08:39:57 PM (11 years ago)
Author:
nacin
Message:

Trac Notifications: Only one API roundtrip for the notifications box.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications-db.php

    r2023 r2024  
    9494        }
    9595
     96        function get_trac_notifications_info( $ticket_id, $username ) {
     97                $meta = array(
     98                        'get_trac_ticket'                              => $this->get_trac_ticket( $ticket_id ),
     99                        'get_trac_ticket_focuses'                      => $this->get_trac_ticket_focuses( $ticket_id ),
     100                        'get_trac_notifications_for_user'              => $this->get_trac_notifications_for_user( $username ),
     101                        'get_trac_ticket_subscription_status_for_user' => $this->get_trac_ticket_subscription_status_for_user( $ticket_id, $username ),
     102                        'get_trac_ticket_subscriptions'                => $this->get_trac_ticket_subscriptions( $ticket_id ),
     103                        'get_trac_ticket_participants'                 => $this->get_trac_ticket_participants( $ticket_id ),
     104                );
     105
     106                if ( $meta['get_trac_ticket']->reporter !== $username ) {
     107                        $meta['get_reporter_last_activity'] = $this->get_reporter_past_activity( $meta['get_trac_ticket']->reporter, $ticket_id );
     108                }
     109
     110                return $meta;
     111        }
     112
    96113        function get_trac_ticket( $ticket_id ) {
    97114                return $this->db->get_row( $this->db->prepare( "SELECT * FROM ticket WHERE id = %d", $ticket_id ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php

    r2023 r2024  
    197197                        exit;
    198198                }
    199                 $ticket = $this->api->get_trac_ticket( $ticket_id );
    200                 if ( ! $ticket ) {
    201                         exit;
    202                 }
    203 
    204                 $focuses = explode( ', ', $this->api->get_trac_ticket_focuses( $ticket_id ) );
    205 
    206                 $notifications = $this->api->get_trac_notifications_for_user( $username );
    207 
    208                 $ticket_sub = $this->api->get_trac_ticket_subscription_status_for_user( $ticket_id, $username );
    209 
    210                 $ticket_subscriptions = $this->api->get_trac_ticket_subscriptions( $ticket_id );
     199
     200                $meta = $this->api->get_trac_notifications_info( $ticket_id, $username );
     201                if ( ! $meta ) {
     202                        exit;
     203                }
     204
     205                $ticket               = $meta['get_trac_ticket'];
     206                $focuses              = $meta['get_trac_ticket_focuses'];
     207                $notifications        = $meta['get_trac_ticket_focuses'];
     208                $ticket_sub           = $meta['get_trac_ticket_subscription_status_for_user'];
     209                $ticket_subscriptions = $meta['get_trac_ticket_subscriptions'];
     210                $participants         = $meta['get_trac_ticket_participants'];
     211
     212                $focuses = explode( ', ', $focuses );
    211213                $stars = $ticket_subscriptions['starred'];
    212214                $star_count = count( $stars );
    213 
    214                 $participants = $this->api->get_trac_ticket_participants( $ticket_id );
    215215
    216216                $unblocked_participants = array_diff( $participants, $ticket_subscriptions['blocked'] );
    … …  
    312312        </div>
    313313        <?php
    314                 $this->ticket_notes( $ticket, $username );
     314                $this->ticket_notes( $ticket, $username, $meta );
    315315                $send = array( 'notifications-box' => ob_get_clean() );
    316316                if ( isset( $this->components ) ) {
    … …  
    321321        }
    322322
    323         function ticket_notes( $ticket, $username ) {
     323        function ticket_notes( $ticket, $username, $meta ) {
    324324                if ( $username == $ticket->reporter ) {
    325325                        return;
    326326                }
    327327
    328                 $activity = $this->api->get_reporter_past_activity( $ticket->reporter, $ticket->id );
     328                $activity = $meta['get_reporter_last_activity'];
    329329
    330330                if ( count( $activity['tickets'] ) >= 5 ) {
Note: See TracChangeset for help on using the changeset viewer.