Skip to content

Commit

Permalink
feat: ability for zapier to poll by new ideas and updated ideas
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcshea committed Jul 10, 2024
1 parent 7521832 commit bdaf783
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/Domain/Ideas/Repositories/Ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,5 +626,40 @@ public function bulkUpdateIdeaStatus($params): bool

return true;
}

/**
* @return array|false
*/
public function getAllIdeas(): array|false
{

// TODO: make this not select * and identify what fields we want back.

$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 pollIdeas(): 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;
}
}
}

0 comments on commit bdaf783

Please sign in to comment.