Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14759241
D17561.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D17561.diff
View Options
diff --git a/src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php b/src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php
@@ -10,13 +10,7 @@
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs(array($id))
- ->needProfile(true)
->needProfileImage(true)
- ->needAvailability(true)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- ))
->executeOne();
if (!$user) {
return new Aphront404Response();
@@ -50,6 +44,7 @@
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
+ ->setLimit(1)
->execute();
$button = id(new PHUIButtonView())
@@ -59,7 +54,7 @@
->setWorkflow(true)
->setHref('/badges/award/'.$user->getID().'/');
- if (count($badges)) {
+ if ($badges) {
$header->addActionLink($button);
}
@@ -80,47 +75,43 @@
private function buildBadgesView(PhabricatorUser $user) {
$viewer = $this->getViewer();
+ $request = $this->getRequest();
+
+ $pager = id(new AphrontCursorPagerView())
+ ->readFromRequest($request);
- $awards = id(new PhabricatorBadgesAwardQuery())
+ $query = id(new PhabricatorBadgesAwardQuery())
->setViewer($viewer)
->withRecipientPHIDs(array($user->getPHID()))
- ->withBadgeStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
- ->execute();
- $awards = mpull($awards, null, 'getBadgePHID');
+ ->withBadgeStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE));
- $badges = array();
- foreach ($awards as $award) {
- $badge = $award->getBadge();
- $badges[$award->getBadgePHID()] = $badge;
- }
+ $awards = $query->executeWithCursorPager($pager);
- if (count($badges)) {
+ if ($awards) {
$flex = new PHUIBadgeBoxView();
+ foreach ($awards as $award) {
+ $badge = $award->getBadge();
+
+ $awarder_info = array();
+
+ $awarder_phid = $award->getAwarderPHID();
+ $awarder_handle = $viewer->renderHandle($awarder_phid);
+ $awarded_date = phabricator_date($award->getDateCreated(), $viewer);
+
+ $awarder_info = pht(
+ 'Awarded by %s',
+ $awarder_handle->render());
+
+ $item = id(new PHUIBadgeView())
+ ->setIcon($badge->getIcon())
+ ->setHeader($badge->getName())
+ ->setSubhead($badge->getFlavor())
+ ->setQuality($badge->getQuality())
+ ->setHref($badge->getViewURI())
+ ->addByLine($awarder_info)
+ ->addByLine($awarded_date);
- foreach ($badges as $badge) {
- if ($badge) {
- $awarder_info = array();
-
- $award = idx($awards, $badge->getPHID(), null);
- $awarder_phid = $award->getAwarderPHID();
- $awarder_handle = $viewer->renderHandle($awarder_phid);
- $awarded_date = phabricator_date($award->getDateCreated(), $viewer);
-
- $awarder_info = pht(
- 'Awarded by %s',
- $awarder_handle->render());
-
- $item = id(new PHUIBadgeView())
- ->setIcon($badge->getIcon())
- ->setHeader($badge->getName())
- ->setSubhead($badge->getFlavor())
- ->setQuality($badge->getQuality())
- ->setHref($badge->getViewURI())
- ->addByLine($awarder_info)
- ->addByLine($awarded_date);
-
- $flex->addItem($item);
- }
+ $flex->addItem($item);
}
} else {
$flex = id(new PHUIInfoView())
@@ -128,6 +119,9 @@
->appendChild(pht('User has not been awarded any badges.'));
}
- return $flex;
+ return array(
+ $flex,
+ $pager,
+ );
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 11:43 AM (8 h, 23 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7036775
Default Alt Text
D17561.diff (3 KB)
Attached To
Mode
D17561: Paginate the profile badges view
Attached
Detach File
Event Timeline
Log In to Comment