Skip to content

Commit

Permalink
Last updated
Browse files Browse the repository at this point in the history
- Missing last updated for resource summary.
- Removed whitespace.
  • Loading branch information
deanblackborough committed Nov 28, 2020
1 parent 04f0a7b commit 25ec803
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/ItemType/Game/ResourceTypeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public function paginatedCollection(
array $sort_parameters = []
): array
{


$select_fields = [
'resource.id AS resource_id',
'resource.name AS resource_name',
Expand Down
22 changes: 22 additions & 0 deletions app/ItemType/Game/SummaryResourceTypeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ public function resourcesSummary(
`item_subtype`.`description` AS resource_item_subtype_description,
COUNT(`{$this->sub_table}`.`item_id`) AS count"
)
->selectRaw("
(
SELECT
GREATEST(
MAX(`{$this->sub_table}`.`created_at`),
IFNULL(MAX(`{$this->sub_table}`.`updated_at`), 0)
)
FROM
`{$this->sub_table}`
JOIN
`item` ON
`{$this->sub_table}`.`item_id` = `{$this->table}`.`id`
JOIN
`resource` ON
`{$this->table}`.`resource_id` = `resource`.`id`
WHERE
`resource`.`resource_type_id` = ?
) AS `last_updated`",
[
$resource_type_id
]
)
->join($this->sub_table, 'item.id', "{$this->sub_table}.item_id")
->join('resource', 'item.resource_id', 'resource.id')
->join('resource_item_subtype', 'resource_item_subtype.resource_id', 'resource.id')
Expand Down

0 comments on commit 25ec803

Please sign in to comment.