1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Fix two issues with user Calendar event availability cache display

Summary:
Ref T11816. Two minor issues:

  - We used `$event`, not `$next_event`, as the event providing the PHID for "Busy at <event name>". This rendered "Busy at <most future event>" on the profile instead of "Busy at <next upcoming event".
  - The TTL computation used the event start, not the event end, so we could end up rebuilding the cache too often for users busy at an event.

Test Plan:
  - Attended an event in the near future and one later on.
  - Saw profile now say "busy at <near future event>" correctly.
  - In DarkConsole "Services" tab, no longer saw unnecessary cache refills while attending an event.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11816

Differential Revision: https://secure.phabricator.com/D17643
This commit is contained in:
epriestley 2017-04-10 04:56:03 -07:00
parent d4d46501ed
commit ab06a9681c
3 changed files with 8 additions and 4 deletions

View file

@ -391,6 +391,10 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return ($epoch - $window);
}
public function getEndDateTimeEpochForCache() {
return $this->getEndDateTimeEpoch();
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,

View file

@ -465,7 +465,7 @@ final class PhabricatorPeopleQuery
while (true) {
foreach ($events as $event) {
$from = $event->getStartDateTimeEpochForCache();
$to = $event->getEndDateTimeEpoch();
$to = $event->getEndDateTimeEpochForCache();
if (($from <= $cursor) && ($to > $cursor)) {
$cursor = $to;
if (!$next_event) {
@ -483,7 +483,7 @@ final class PhabricatorPeopleQuery
$availability_type = $invitee->getDisplayAvailability($next_event);
$availability = array(
'until' => $cursor,
'eventPHID' => $event->getPHID(),
'eventPHID' => $next_event->getPHID(),
'availability' => $availability_type,
);
@ -496,7 +496,7 @@ final class PhabricatorPeopleQuery
// simultaneously we should accommodate that. However, it's complex
// to compute, rare, and probably not confusing most of the time.
$availability_ttl = $next_event->getStartDateTimeEpochForCache();
$availability_ttl = $next_event->getEndDateTimeEpochForCache();
} else {
$availability = array(
'until' => null,

View file

@ -1082,7 +1082,7 @@ final class PhabricatorUser
'UPDATE %T SET availabilityCache = %s, availabilityCacheTTL = %nd
WHERE id = %d',
$this->getTableName(),
json_encode($availability),
phutil_json_encode($availability),
$ttl,
$this->getID());
unset($unguarded);