Making WordPress.org


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.