Skip to content

Commit

Permalink
export json data of commments
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt committed Jul 19, 2024
1 parent 5439304 commit 9ef51a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/Command/UserExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\Deck\Db\StackMapper;
use OCA\Deck\Model\CardDetails;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\CommentService;
use OCP\App\IAppManager;
use OCP\DB\Exception;
use Symfony\Component\Console\Command\Command;
Expand All @@ -27,6 +28,7 @@ public function __construct(
private StackMapper $stackMapper,
private CardMapper $cardMapper,
private AssignmentMapper $assignedUsersMapper,
private CommentService $commentService,
) {
parent::__construct();
}
Expand Down Expand Up @@ -56,6 +58,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$data = [];
foreach ($boards as $board) {
if ($board->getDeletedAt() > 0) {
continue;
}
$fullBoard = $this->boardMapper->find($board->getId(), true, true);
$data[$board->getId()] = $fullBoard->jsonSerialize();
$stacks = $this->stackMapper->findAll($board->getId());
Expand All @@ -68,7 +73,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$fullCard->setAssignedUsers($assignedUsers);

$cardDetails = new CardDetails($fullCard, $fullBoard);
$data[$board->getId()]['stacks'][$stack->getId()]['cards'][] = $cardDetails->jsonSerialize();
$comments = $this->commentService->list($card->getId());

$cardDetails->setCommentsCount(count($comments->getData()));

$cardJson = $cardDetails->jsonSerialize();
$cardJson['comments'] = $comments->getData();
$data[$board->getId()]['stacks'][$stack->getId()]['cards'][] = $cardJson;
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions lib/Service/Importer/Systems/DeckJsonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace OCA\Deck\Service\Importer\Systems;

use OC\Comments\Comment;
use OCA\Deck\BadRequestException;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\Assignment;
Expand Down Expand Up @@ -103,8 +104,17 @@ public function getCardAssignments(): array {
}

public function getComments(): array {
// Comments are not implemented in export
return [];
$comments = [];
foreach ($this->tmpCards as $sourceCard) {
$commentsOriginal = $sourceCard->comments;
foreach ($commentsOriginal as $commentOriginal) {
$comment = new Comment();
$comment->setActor($commentOriginal->actorType, $commentOriginal->actorId)
->setMessage($commentOriginal->message)->setCreationDateTime(\DateTime::createFromFormat('Y-m-d\TH:i:sP', $commentOriginal->creationDateTime));
$comments[$this->cards[$sourceCard->id]->getId()][$commentOriginal->id] = $comment;
}
}
return $comments;
}

public function getCardLabelAssignment(): array {
Expand Down

0 comments on commit 9ef51a0

Please sign in to comment.