Skip to content

Commit

Permalink
Merge pull request #2577 from kylemcshea/master
Browse files Browse the repository at this point in the history
feat: zapier integration
  • Loading branch information
marcelfolaron authored Jul 25, 2024
2 parents 34a98b5 + ace4faf commit 422e19f
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 77 deletions.
21 changes: 21 additions & 0 deletions app/Domain/Comments/Repositories/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,26 @@ public function editComment($text, $id): bool
$stmn->closeCursor();
return $result;
}

public function getAllAccountComments(): array|false
{
$sql = "SELECT comment.id,
comment.module,
comment.text,
comment.date,
comment.moduleId,
comment.userId,
comment.commentParent,
comment.status
FROM zp_comment as comment";

$stmn = $this->db->database->prepare($sql);

$stmn->execute();
$values = $stmn->fetchAll();
$stmn->closeCursor();

return $values;
}
}
}
5 changes: 4 additions & 1 deletion app/Domain/Comments/Services/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public function deleteComment($commentId): bool
return $this->commentRepository->deleteComment($commentId);
}

public function pollComments(): array | false
{
return $this->commentRepository->getAllAccountComments();
}
}

}
65 changes: 61 additions & 4 deletions app/Domain/Goalcanvas/Repositories/Goalcanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class Goalcanvas extends Canvas
* @var array
*/
protected array $dataLabels = [
1 => ['title' => 'label.what_are_you_measuring', 'field' => 'assumptions', 'type' => 'string', 'active' => true],
2 => ['title' => 'label.current_value', 'field' => 'data', 'type' => 'int', 'active' => true],
3 => ['title' => 'label.goal_value', 'field' => 'conclusion', 'type' => 'int', 'active' => true],
1 => ['title' => 'label.what_are_you_measuring', 'field' => 'assumptions', 'type' => 'string', 'active' => true],
2 => ['title' => 'label.current_value', 'field' => 'data', 'type' => 'int', 'active' => true],
3 => ['title' => 'label.goal_value', 'field' => 'conclusion', 'type' => 'int', 'active' => true],

];
];


/**
Expand Down Expand Up @@ -159,5 +159,62 @@ public function getSingleCanvas($canvasId): false|array

return $values;
}

/**
* Gets all goals related to a milestone
*
* @return array|false
*/
public function getAllAccountGoals(): false|array
{
$sql = "SELECT
zp_canvas_items.id,
zp_canvas_items.description,
zp_canvas_items.title,
zp_canvas_items.assumptions,
zp_canvas_items.data,
zp_canvas_items.conclusion,
zp_canvas_items.box,
zp_canvas_items.author,
zp_canvas_items.created,
zp_canvas_items.modified,
zp_canvas_items.canvasId,
zp_canvas_items.sortindex,
zp_canvas_items.status,
zp_canvas_items.relates,
zp_canvas_items.milestoneId,
zp_canvas_items.kpi,
zp_canvas_items.data1,
zp_canvas_items.data2,
zp_canvas_items.data3,
zp_canvas_items.data4,
zp_canvas_items.data5,
zp_canvas_items.startDate,
zp_canvas_items.endDate,
zp_canvas_items.setting,
zp_canvas_items.metricType,
zp_canvas_items.startValue,
zp_canvas_items.currentValue,
zp_canvas_items.endValue,
zp_canvas_items.impact,
zp_canvas_items.effort,
zp_canvas_items.probability,
zp_canvas_items.action,
zp_canvas_items.assignedTo,
zp_canvas_items.parent,
zp_canvas_items.tags
FROM
zp_canvas_items
WHERE zp_canvas_items.box = 'goal'
";

$stmn = $this->db->database->prepare($sql);
$stmn->execute();
$values = $stmn->fetchAll();
$stmn->closeCursor();
return $values;
}
}
}
24 changes: 20 additions & 4 deletions app/Domain/Goalcanvas/Services/Goalcanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,35 @@ public function getGoalsByMilestone($milestoneId): array
return $goals;
}

public function updateGoalboard($values) {
public function updateGoalboard($values)
{
return $this->goalRepository->updateCanvas($values);
}

public function createGoalboard($values) {
public function createGoalboard($values)
{
return $this->goalRepository->addCanvas($values);
}

public function getSingleCanvas($id) {
public function getSingleCanvas($id)
{
return $this->goalRepository->getSingleCanvas($id);
}

public function pollGoals()
{
return $this->goalRepository->getAllAccountGoals();
}

}
public function pollForUpdatedGoals(): array|false
{
$goals = $this->goalRepository->getAllAccountGoals();

foreach ($goals as $key => $goal) {
$goals[$key]['id'] = $goal['id'] . '-' . $goal['modified'];
}

return $goals;
}
}
}
29 changes: 29 additions & 0 deletions app/Domain/Ideas/Repositories/Ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,5 +626,34 @@ public function bulkUpdateIdeaStatus($params): bool

return true;
}

public function getAllIdeas(): array|false
{
$sql = "SELECT zp_canvas_items.id,
zp_canvas_items.description,
zp_canvas_items.assumptions,
zp_canvas_items.data,
zp_canvas_items.conclusion,
zp_canvas_items.box,
zp_canvas_items.author,
zp_canvas_items.created,
zp_canvas_items.modified,
zp_canvas_items.canvasId,
zp_canvas_items.sortindex,
zp_canvas_items.status,
zp_canvas_items.tags,
zp_canvas_items.milestoneId
FROM zp_canvas_items
LEFT JOIN zp_canvas AS canvasBoard ON zp_canvas_items.canvasId = canvasBoard.id
WHERE canvasBoard.type = 'idea'";

$stmn = $this->db->database->prepare($sql);

$stmn->execute();
$values = $stmn->fetchAll(PDO::FETCH_ASSOC);
$stmn->closeCursor();

return $values;
}
}
}
32 changes: 32 additions & 0 deletions app/Domain/Ideas/Services/Ideas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Leantime\Domain\Ideas\Services {

use Leantime\Domain\Ideas\Repositories\Ideas as IdeasRepository;

class Ideas
{
private IdeasRepository $ideasRepository;

public function __construct(IdeasRepository $ideasRepository)
{
$this->ideasRepository = $ideasRepository;
}

public function pollForNewIdeas(): array
{
return $this->ideasRepository->getAllIdeas();
}

public function pollForUpdatedIdeas(): array
{
$ideas = $this->ideasRepository->getAllIdeas();

foreach ($ideas as $key => $idea) {
$ideas[$key]['id'] = $idea['id'] . '-' . $idea['modified'];
}

return $ideas;
}
}
}
13 changes: 6 additions & 7 deletions app/Domain/Install/Repositories/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ private function sqlPrep(): string
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
insert into `zp_tickets`(`id`,`projectId`,`headline`,`description`,`acceptanceCriteria`,`date`,`dateToFinish`,`priority`,`status`,`userId`,`os`,`browser`,`resolution`,`component`,`version`,`url`,`milestoneid`,`editFrom`,`editTo`,`editorId`,`planHours`,`hourRemaining`,`type`,`production`,`staging`,`storypoints`,`sprint`,`sortindex`,`kanbanSortIndex`) values
(9,3,'Getting Started with Leantime', '".$gettingStartedDescription."','','".date("Y-m-d")."','".date("Y-m-d")."',2,3,1,NULL,NULL,NULL,NULL,'',NULL,NULL,'1969-12-31 00:00:00','1969-12-31 00:00:00',1,0,0,'Story',0,0,0,0,NULL,NULL);
(9,3,'Getting Started with Leantime', '" . $gettingStartedDescription . "','','" . date("Y-m-d") . "','" . date("Y-m-d") . "',2,3,1,NULL,NULL,NULL,NULL,'',NULL,NULL,'1969-12-31 00:00:00','1969-12-31 00:00:00',1,0,0,'Story',0,0,0,0,NULL,NULL);
CREATE TABLE `zp_timesheets` (
`id` int(255) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -1316,11 +1316,11 @@ private function update_sql_20111(): bool|array
"UPDATE zp_projects SET menuType = '" . MenuRepository::DEFAULT_MENU . "'",
"ALTER TABLE zp_canvas_items ADD relates VARCHAR(255) null",
"UPDATE zp_canvas_items INNER JOIN zp_canvas ON zp_canvas.id = zp_canvas_items.id " .
"SET zp_canvas_items.status = 'draft' WHERE zp_canvas_items.status = 'danger' AND zp_canvas.type = 'leancanvas'",
"SET zp_canvas_items.status = 'draft' WHERE zp_canvas_items.status = 'danger' AND zp_canvas.type = 'leancanvas'",
"UPDATE zp_canvas_items INNER JOIN zp_canvas ON zp_canvas.id = zp_canvas_items.id " .
"SET zp_canvas_items.status = 'valid' WHERE zp_canvas_items.status = 'sucess' AND zp_canvas.type = 'leancanvas'",
"SET zp_canvas_items.status = 'valid' WHERE zp_canvas_items.status = 'sucess' AND zp_canvas.type = 'leancanvas'",
"UPDATE zp_canvas_items INNER JOIN zp_canvas ON zp_canvas.id = zp_canvas_items.id " .
"SET zp_canvas_items.status = 'invalid' WHERE zp_canvas_items.status = 'info' AND zp_canvas.type = 'leancanvas'",
"SET zp_canvas_items.status = 'invalid' WHERE zp_canvas_items.status = 'info' AND zp_canvas.type = 'leancanvas'",
"UPDATE zp_canvas SET zp_canvas.type = 'retroscanvas' WHERE zp_canvas.type = 'retrospective'",
];

Expand Down Expand Up @@ -1909,7 +1909,8 @@ public function update_sql_20407(): bool|array
}
}

public function update_sql_30002(): bool|array {
public function update_sql_30002(): bool|array
{

$errors = array();

Expand Down Expand Up @@ -1956,8 +1957,6 @@ public function update_sql_30003(): bool|array {


return true;

}

}
}
Loading

0 comments on commit 422e19f

Please sign in to comment.