Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show total count #13

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Show total count #13

wants to merge 26 commits into from

Conversation

holingpoon
Copy link

Let's find a time to talk about this? Thanks!

@holingpoon holingpoon self-assigned this Mar 1, 2018
@holingpoon holingpoon requested a review from kfriedman March 1, 2018 16:44
@@ -249,6 +249,10 @@ protected function getDefaultReadResponse(

$model->setLimit($this->getRequest()->getParam('limit'));

if ($this->getRequest()->getParam('include_count') == 'true') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to do strict checking ===

@holingpoon
Copy link
Author

@kfriedman, ready for review 🙂

Copy link
Contributor

@kfriedman kfriedman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Looks very solid to me.

*/
$baseModel = $this->getBaseModel();

$selectStatement = DB::getDatabase()->select()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -289,6 +290,10 @@ protected function setSet($ignoreNoRecord = false)
}

if ($selectStatement->rowCount()) {
if ($this->isIncludeTotalCount() == true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use strict checking

@@ -289,6 +290,10 @@ protected function setSet($ignoreNoRecord = false)
}

if ($selectStatement->rowCount()) {
if ($this->isIncludeTotalCount() === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove checking for true

@@ -249,6 +249,12 @@ protected function getDefaultReadResponse(

$model->setLimit($this->getRequest()->getParam('limit'));

$includeTotalCount = $this->getRequest()->getParam('includeTotalCount') === 'true' ? true : false ;

if ($includeTotalCount === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove checking for true here if you're sure it's going to be boolean

*/
public function initializeResponse($model)
{
if (is_array($model)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor out elses; you can just use return statements

{
if (is_array($model)) {
$this->initializeArrayOfModels($model);
} else if ($model instanceof ModelSet) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move ModelSet to end to indicate it's the newest functionality?

src/ModelSet.php Outdated
*/
public function setIncludeTotalCount($includeTotalCount)
{
$this->includeTotalCount = $includeTotalCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe typecast the $includeTotalCount to (bool)?

src/ModelSet.php Outdated
*/
public function setTotalCount($totalCount = 0)
{
$this->totalCount = $totalCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe typecast $totalCount to (int)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants