コード例 #1
0
 public function execute()
 {
     $table = new ConpherenceParticipant();
     $conn_r = $table->establishConnection('r');
     $rows = queryfx_all($conn_r, 'SELECT COUNT(*) as count, participantPHID ' . 'FROM %T participant %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildGroupByClause($conn_r), $this->buildLimitClause($conn_r));
     return ipull($rows, 'count', 'participantPHID');
 }
コード例 #2
0
 public function execute()
 {
     $table = new ConpherenceParticipant();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T participant %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     $participants = $table->loadAllFromArray($data);
     $participants = mpull($participants, null, 'getConpherencePHID');
     if ($this->order == self::ORDER_NEWER) {
         $participants = array_reverse($participants);
     }
     return $participants;
 }
コード例 #3
0
<?php

echo pht("Migrating data from conpherence transactions to conpherence 'cache'...\n");
$table = new ConpherenceThread();
$table->openTransaction();
$conn_w = $table->establishConnection('w');
$participant_table = new ConpherenceParticipant();
$conpherences = new LiskMigrationIterator($table);
foreach ($conpherences as $conpherence) {
    echo pht('Migrating conpherence #%d', $conpherence->getID()) . "\n";
    $participants = id(new ConpherenceParticipant())->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
    $transactions = id(new ConpherenceTransaction())->loadAllWhere('objectPHID = %s', $conpherence->getPHID());
    $participation_hash = mgroup($participants, 'getBehindTransactionPHID');
    $message_count = 0;
    $participants_to_cache = array();
    foreach ($transactions as $transaction) {
        $participants_to_cache[] = $transaction->getAuthorPHID();
        if ($transaction->getTransactionType() == PhabricatorTransactions::TYPE_COMMENT) {
            $message_count++;
        }
        $participants_to_update = idx($participation_hash, $transaction->getPHID(), array());
        if ($participants_to_update) {
            queryfx($conn_w, 'UPDATE %T SET seenMessageCount = %d ' . 'WHERE conpherencePHID = %s AND participantPHID IN (%Ls)', $participant_table->getTableName(), $message_count, $conpherence->getPHID(), mpull($participants_to_update, 'getParticipantPHID'));
        }
    }
    $participants_to_cache = array_slice(array_unique(array_reverse($participants_to_cache)), 0, 10);
    queryfx($conn_w, 'UPDATE %T ' . 'SET recentParticipantPHIDs = %s, ' . 'messageCount = %d ' . 'WHERE phid = %s', $table->getTableName(), json_encode($participants_to_cache), $message_count, $conpherence->getPHID());
}
$table->saveTransaction();
echo "\n" . pht('Done.') . "\n";
コード例 #4
0
 public function getScrollMenuItem(ConpherenceParticipant $participant, $direction)
 {
     if ($direction == 'up') {
         $name = pht('Load Newer Threads');
     } else {
         $name = pht('Load Older Threads');
     }
     $item = id(new PHUIListItemView())->addSigil('conpherence-menu-scroller')->setName($name)->setHref($this->baseURI)->setType(PHUIListItemView::TYPE_BUTTON)->setMetadata(array('participant_id' => $participant->getID(), 'conpherence_phid' => $participant->getConpherencePHID(), 'date_touched' => $participant->getDateTouched(), 'direction' => $direction));
     return $item;
 }
コード例 #5
0
 /**
  * Handles the curious case when we are visiting a conpherence directly
  * by issuing two separate queries. Otherwise, additional conpherences
  * are fetched asynchronously. Note these can be earlier or later
  * (up or down), depending on what conpherence was selected on initial
  * load.
  */
 private function loadParticipationWithMidCursor(ConpherenceParticipant $cursor)
 {
     $user = $this->getRequest()->getUser();
     $scroll_up_participant = $this->getEmptyParticipant();
     $scroll_down_participant = $this->getEmptyParticipant();
     // Note this is a bit dodgy since there may be less than this
     // amount in either the up or down direction, thus having us fail
     // to fetch LIMIT in total. Whatevs for now and re-visit if we're
     // fine-tuning this loading process.
     $too_many = ceil(ConpherenceParticipantQuery::LIMIT / 2) + 1;
     $participant_query = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit($too_many);
     $current_selection_epoch = $cursor->getDateTouched();
     $set_one = $participant_query->withParticipantCursor($cursor)->setOrder(ConpherenceParticipantQuery::ORDER_NEWER)->execute();
     if (count($set_one) == $too_many) {
         $node = reset($set_one);
         unset($set_one[$node->getConpherencePHID()]);
         $scroll_up_participant = $node;
     }
     $set_two = $participant_query->withParticipantCursor($cursor)->setOrder(ConpherenceParticipantQuery::ORDER_OLDER)->execute();
     if (count($set_two) == $too_many) {
         $node = end($set_two);
         unset($set_two[$node->getConpherencePHID()]);
         $scroll_down_participant = $node;
     }
     $participation = array_merge($set_one, $set_two);
     return array('scroll_up_participant' => $scroll_up_participant, 'scroll_down_participant' => $scroll_down_participant, 'participation' => $participation);
 }