Add last_modified to board/stack database and add check on index methods

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-27 15:56:07 +02:00
parent 38bc02c07e
commit a068d6e1c6
12 changed files with 113 additions and 60 deletions

View File

@@ -24,6 +24,7 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\ChangeHelper;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -60,9 +61,14 @@ class BoardApiController extends ApiController {
* Return all of the boards that the current user has access to.
*/
public function index() {
$boards = $this->service->findAll();
$modified = $this->request->getHeader('If-Modified-Since');
if ($modified === '') {
$boards = $this->service->findAll();
} else {
$boards = $this->service->findAll(strtotime($modified));
}
return new DataResponse($boards, HTTP::STATUS_OK);
}
}
/**
* @NoAdminRequired
@@ -87,8 +93,8 @@ class BoardApiController extends ApiController {
*
* Create a board with the specified title and color.
*/
public function create($title, $color) {
$board = $this->service->create($title, $this->userId, $color);
public function create($title, $color) {
$board = $this->service->create($title, $this->userId, $color);
return new DataResponse($board, HTTP::STATUS_OK);
}
@@ -96,14 +102,14 @@ class BoardApiController extends ApiController {
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
*
* @params $title
* @params $color
* @params $archived
* @params $color
* @params $archived
*
* Update a board with the specified boardId, title and color, and archived state.
*/
public function update($title, $color, $archived = false) {
public function update($title, $color, $archived = false) {
$board = $this->service->update($this->request->getParam('boardId'), $title, $color, $archived);
return new DataResponse($board, HTTP::STATUS_OK);
}
@@ -112,7 +118,7 @@ class BoardApiController extends ApiController {
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
*
*
* Delete the board specified by $boardId. Return the board that was deleted.
*/
@@ -125,12 +131,12 @@ class BoardApiController extends ApiController {
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
*
*
* Undo the deletion of the board specified by $boardId.
*/
public function undoDelete() {
$board = $this->service->deleteUndo($this->request->getParam('boardId'));
public function undoDelete() {
$board = $this->service->deleteUndo($this->request->getParam('boardId'));
return new DataResponse($board, HTTP::STATUS_OK);
}

View File

@@ -23,6 +23,7 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\ChangeHelper;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -35,8 +36,8 @@
* @package OCA\Deck\Controller
*/
class CardApiController extends ApiController {
private $cardService;
private $userId;
private $cardService;
private $userId;
/**
* @param string $appName
@@ -45,9 +46,9 @@ class CardApiController extends ApiController {
* @param $userId
*/
public function __construct($appName, IRequest $request, CardService $cardService, $userId) {
parent::__construct($appName, $request);
$this->cardService = $cardService;
$this->userId = $userId;
parent::__construct($appName, $request);
$this->cardService = $cardService;
$this->userId = $userId;
}
/**
@@ -118,8 +119,8 @@ class CardApiController extends ApiController {
/**
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* @NoCSRFRequired
*
* Assign a label to a card.
*/
public function removeLabel($labelId) {
@@ -130,8 +131,8 @@ class CardApiController extends ApiController {
/**
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* @NoCSRFRequired
*
* Unassign a label to a card.
*/
public function unassignUser($userId) {
@@ -147,12 +148,12 @@ class CardApiController extends ApiController {
/**
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* @NoCSRFRequired
*
* Unassign a label to a card.
*/
public function reorder($stackId, $order) {
$card = $this->cardService->reorder($this->request->getParam('cardId'), $stackId, $order);
return new DataResponse($card, HTTP::STATUS_OK);
}
}
}

View File

@@ -49,7 +49,7 @@ class StackApiController extends ApiController {
public function __construct($appName, IRequest $request, StackService $stackService, BoardService $boardService) {
parent::__construct($appName, $request);
$this->stackService = $stackService;
$this->boardService = $boardService;
$this->boardService = $boardService;
}
/**
@@ -59,8 +59,13 @@ class StackApiController extends ApiController {
*
* Return all of the stacks in the specified board.
*/
public function index() {
$stacks = $this->stackService->findAll($this->request->getParam('boardId'));
public function index() {
$since = 0;
$modified = $this->request->getHeader('If-Modified-Since');
if ($modified !== '') {
$since = strtotime($modified);
}
$stacks = $this->stackService->findAll($this->request->getParam('boardId'), $since);
return new DataResponse($stacks, HTTP::STATUS_OK);
}
@@ -75,7 +80,7 @@ class StackApiController extends ApiController {
$stack = $this->stackService->find($this->request->getParam('stackId'));
return new DataResponse($stack, HTTP::STATUS_OK);
}
/**
* @NoAdminRequired
* @CORS
@@ -95,13 +100,13 @@ class StackApiController extends ApiController {
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* @params $title
*
* @params $title
* @params $order
*
* Update a stack by the specified stackId and boardId with the values that were put.
*/
public function update($title, $order) {
public function update($title, $order) {
$stack = $this->stackService->update($this->request->getParam('stackId'), $title, $this->request->getParam('boardId'), $order, 0);
return new DataResponse($stack, HTTP::STATUS_OK);
}
@@ -113,7 +118,7 @@ class StackApiController extends ApiController {
*
* Delete the stack specified by $this->request->getParam('stackId').
*/
public function delete() {
public function delete() {
$stack = $this->stackService->delete($this->request->getParam('stackId'));
return new DataResponse($stack, HTTP::STATUS_OK);
}