Skip to content

Commit

Permalink
Fix for broken project favorite function
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 16, 2024
1 parent a68aaeb commit 9fd512b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/Domain/Projects/Hxcontrollers/ProjectCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public function toggleFavorite()

$this->setHTMXEvent("HTMX.updateProjectList");


$project = $this->projectsService->getProject($projectId);
$this->tpl->assign("project", $project);
}

public function getProgress() {
Expand All @@ -132,6 +133,8 @@ public function getProgress() {

$currentUrlPath = BASE_URL . "/" . str_replace(".", "/", Frontcontroller::getCurrentRoute());

$project = $this->projectsService->getProject($projectId);

$this->tpl->assign("projectTypeAvatars", $projectTypeAvatars);
$this->tpl->assign("currentUrlPath", $currentUrlPath);
$this->tpl->assign("project", $project);
Expand Down
9 changes: 8 additions & 1 deletion app/Domain/Projects/Repositories/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,18 @@ public function getProject($id): array|bool
SUM(case when zp_tickets.type <> 'milestone' then 1 else 0 end) as numberOfTickets,
SUM(case when zp_tickets.type = 'milestone' then 1 else 0 end) as numberMilestones,
COUNT(relation.projectId) AS numUsers,
COUNT(definitionCanvas.id) AS numDefinitionCanvas
COUNT(definitionCanvas.id) AS numDefinitionCanvas,
IF(favorite.id IS NULL, false, true) as isFavorite
FROM zp_projects
LEFT JOIN zp_tickets ON zp_projects.id = zp_tickets.projectId
LEFT JOIN zp_clients ON zp_projects.clientId = zp_clients.id
LEFT JOIN zp_relationuserproject as relation ON zp_projects.id = relation.projectId
LEFT JOIN zp_canvas as definitionCanvas ON zp_projects.id = definitionCanvas.projectId AND definitionCanvas.type NOT IN('idea', 'retroscanvas', 'goalcanvas', 'wiki')
LEFT JOIN zp_reactions as favorite ON zp_projects.id = favorite.moduleId
AND favorite.module = 'project'
AND favorite.reaction = 'favorite'
AND favorite.userId = :id
LEFT JOIN zp_user as requestingUser ON requestingUser.id = :id
WHERE zp_projects.id = :projectId
GROUP BY
zp_projects.id,
Expand All @@ -516,6 +522,7 @@ public function getProject($id): array|bool

$stmn = $this->db->database->prepare($query);
$stmn->bindValue(':projectId', $id, PDO::PARAM_INT);
$stmn->bindValue(':id', session("userdata.id"), PDO::PARAM_STR);

$stmn->execute();
$values = $stmn->fetch();
Expand Down

0 comments on commit 9fd512b

Please sign in to comment.