Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove relevant uodates #31

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
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: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@ indent_style = tab
# phpstan.neon
[*.neon]
indent_style = tab

# Ignore paths
[/var/**]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset

[package-lock.json]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
116 changes: 0 additions & 116 deletions Classes/Backend/ToolbarItems/UpdateItem.php

This file was deleted.

102 changes: 0 additions & 102 deletions Classes/Command/NotifyUpdateCommand.php

This file was deleted.

13 changes: 0 additions & 13 deletions Classes/Utility/ContentUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ public static function getPage(int $pageId): array|bool
return $pageRepository->getPage($pageId);
}

public static function getAssignedPages(): array|bool
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');

return $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('tx_ximatypo3contentplanner_assignee', $queryBuilder->createNamedParameter($GLOBALS['BE_USER']->user['uid'], \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->executeQuery()->fetchAllAssociative();
}

public static function getRecordsByFilter(?string $search = null, ?int $status = null, ?int $assignee = null, ?string $type = null, int $maxResults = 20): array|bool
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
Expand Down
67 changes: 1 addition & 66 deletions Classes/Widgets/Provider/ContentUpdateDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
use Xima\XimaTypo3ContentPlanner\Configuration;
use Xima\XimaTypo3ContentPlanner\Domain\Model\Dto\HistoryItem;
use Xima\XimaTypo3ContentPlanner\Utility\ContentUtility;

class ContentUpdateDataProvider implements ListDataProviderInterface
{
Expand All @@ -21,7 +20,7 @@ public function getItems(): array
return $this->fetchUpdateData(maxItems: 15);
}

public function fetchUpdateData(bool $relevanteUpdatesForCurrentUser = false, ?int $beUser = null, ?int $tstamp = null, ?int $maxItems = null, bool $cliContext = false): array
public function fetchUpdateData(?int $beUser = null, ?int $tstamp = null, ?int $maxItems = null, bool $cliContext = false): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_history');

Expand Down Expand Up @@ -52,14 +51,6 @@ public function fetchUpdateData(bool $relevanteUpdatesForCurrentUser = false, ?i
$query->setMaxResults($maxItems*2);
}

// Filter for relevant history entries, which are not created by the current user
if ($relevanteUpdatesForCurrentUser) {
$query
->andWhere('h.userid != :userid')
->andWhere('p.tx_ximatypo3contentplanner_assignee = :userid')
->setParameter('userid', $beUser ?: $GLOBALS['BE_USER']->user['uid']);
}

if ($tstamp) {
$query->andWhere('h.tstamp > :tstamp')
->setParameter('tstamp', $tstamp);
Expand All @@ -76,16 +67,6 @@ public function fetchUpdateData(bool $relevanteUpdatesForCurrentUser = false, ?i
}
}

if ($relevanteUpdatesForCurrentUser) {
$additionalItems = $this->getRecentRelevantCommentsForUser($beUser);
$items = array_merge($items, $additionalItems);

// sort by tstamp
usort($items, function ($a, $b) {
return $b->data['tstamp'] <=> $a->data['tstamp'];
});
}

foreach ($items as $key => $item) {
if ($item->getHistoryData() === '') {
unset($items[$key]);
Expand All @@ -98,50 +79,4 @@ public function fetchUpdateData(bool $relevanteUpdatesForCurrentUser = false, ?i

return $items;
}

/*
* It's a workaround to fetch all comments and afterwards filter them by assigned pages, because this information is serialized and cannot be filtered within the query
*/
private function getRecentRelevantCommentsForUser(?int $beUser = null): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_history');

$query = $queryBuilder
->select(
'h.uid',
'h.tstamp as tstamp',
'h.recuid as recuid',
'h.userid as userid',
'h.actiontype as actiontype',
'h.tablename as tablename',
'h.history_data as history_data',
'b.username as username',
)
->from('sys_history', 'h')
->leftJoin('h', 'be_users', 'b', 'h.userid = b.uid')
->andWhere('h.userid != :userid')
->andWhere('h.tablename = "tx_ximatypo3contentplanner_comment"')
->orderBy('h.tstamp', 'DESC')
->setParameter('userid', $beUser ?: $GLOBALS['BE_USER']->user['uid']);

$assignedPages = ContentUtility::getAssignedPages();
// only get uids from assigned pages
$uids = array_map(function ($page) {
return $page['uid'];
}, $assignedPages);

$items = [];
$results = $query->executeQuery()
->fetchAllAssociative();

foreach ($results as $result) {
try {
if (!is_null($result['history_data']) && in_array(json_decode($result['history_data'], true)['pid'], $uids)) {
$items[] = HistoryItem::create($result);
}
} catch (\Exception $e) {
}
}
return $items;
}
}
15 changes: 0 additions & 15 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ services:
resource: '../Classes/*'
exclude: '../Classes/Domain/Model/*'

cache.ximatypo3contentplanner_toolbarcache:
class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
factory: [ '@TYPO3\CMS\Core\Cache\CacheManager', 'getCache' ]
arguments: [ 'ximatypo3contentplanner_toolbarcache' ]

Xima\XimaTypo3ContentPlanner\Backend\ToolbarItems\UpdateItem:
arguments:
$cache: '@cache.ximatypo3contentplanner_toolbarcache'

Xima\XimaTypo3ContentPlanner\EventListener\DrawBackendHeaderListener:
tags:
- name: event.listener
Expand All @@ -42,12 +33,6 @@ services:
- name: event.listener
identifier: 'xima-typo3-content-planner/backend/modify-record-list-record-actions'

Xima\XimaTypo3ContentPlanner\Command\NotifyUpdateCommand:
tags:
- name: console.command
command: 'content-planner:notifiy-update'
description: 'A command to notify users about relevant updates in the content planner.'

Xima\XimaTypo3ContentPlanner\Command\BulkUpdateCommand:
tags:
- name: console.command
Expand Down
Loading