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

Readability cleanup on EventIncome report (towards bringing it under testing) #13963

Merged
merged 1 commit into from
Apr 20, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Apr 5, 2019

Overview

Minor readability cleanup, preparatory to extracting buildQuery & bringing it under testing

Before

Less readable

After

More readable

Technical Details

@lcdservices I took a look at this PR #13928 but didn't really feel comfortable making any functional changes to the report before we bring it under unit test - it's one of 3 reports specifically excluded :-(

The main thing we need to do is extract the code that generates $sql to be in a function called buildQuery that takes no arguments

In order to do that I felt some minor cleanup had to happen first - this is just getting the status stuff into a more extractable form.

I also noticed your PR is hard to read due to reformatting - we can fix the formatting in the cleanup PRs. Let me know if this seems good to you...

Comments

@civibot
Copy link

civibot bot commented Apr 5, 2019

(Standard links)

@civibot civibot bot added the master label Apr 5, 2019
@eileenmcnaughton eileenmcnaughton changed the title Readability cleanup on EventIncome report to bring it under testing Readability cleanup on EventIncome report (towards bringing it under testing) Apr 5, 2019
@eileenmcnaughton
Copy link
Contributor Author

test this please

1 similar comment
@eileenmcnaughton
Copy link
Contributor Author

test this please

$activeParticipantStatuses = [];
foreach (CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label") as $id => $label) {
$activeParticipantStatuses[$id] = $label;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not $activeParticipantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label"); or return CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @pradpnayak on looking into it your suggestions make sense & improve readability - I have updated the PR

@@ -216,6 +208,7 @@ public function buildEventReport($eventIDs) {

$statusDAO = $this->executeReportQuery($status);

$participantStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using $participantStatus = $this->getActiveParticipantStatuses();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated per below

@pradpnayak
Copy link
Contributor

Looks good now. Good to merge!

@seamuslee001
Copy link
Contributor

Merging as per Pradeep's review

@seamuslee001 seamuslee001 merged commit 2617d84 into civicrm:master Apr 20, 2019
@eileenmcnaughton eileenmcnaughton deleted the event_report branch July 3, 2019 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants