Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion application/pages/default/ConsumePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,35 @@ public function beforeView()
usort($byFirstName, function($a, $b) {
return strcmp(strtolower($a[User::FIELD_FIRST_NAME]), strtolower($b[User::FIELD_FIRST_NAME]));
});
$byFirstName = array_filter($byFirstName, function($a) {
$timeStamp = strtotime($a['time']);
$cutOffDate = strtotime('-6 months');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 months where PR says 3 months 😕


return ($timeStamp > $cutOffDate);
});

$byLastName = $allUsersByRole[Role::ROLE_USER];
usort($byLastName, function($a, $b) {
return strcmp(strtolower($a[User::FIELD_LAST_NAME]), strtolower($b[User::FIELD_LAST_NAME]));
});
$byLastName = array_filter($byLastName, function($a) {
$timeStamp = strtotime($a['time']);
$cutOffDate = strtotime('-6 months');

return ($timeStamp > $cutOffDate);
});
Comment on lines +53 to +58
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code quality wise I would have factored out the filter function into a separate named function. Then both filters can use the same logic twice.

DRY for only two instances of the code is often just an edge care. So I'm fine keeping it like this. More of a general remark.


$byAmount = $allUsersByRole[Role::ROLE_USER];
usort($byAmount, function($a, $b) {
return $b['amount'] - $a['amount'];
});

$byLatest = $allUsersByRole[Role::ROLE_USER];
usort($byLatest, function($a, $b) {
$timeStamp1 = strtotime($a['time']);
$timeStamp2 = strtotime($b['time']);
return $timeStamp2 - $timeStamp1;
});;
});

$tabs = [
'ordered-first-name' => [
Expand Down