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

Update circuit playground discount code applications for 2020 #32179

Merged
merged 35 commits into from Dec 21, 2019

Conversation

bencodeorg
Copy link
Contributor

@bencodeorg bencodeorg commented Nov 27, 2019

Description

  1. Updates "high needs" bar eligibility for discount codes from 40% eligible for free and reduced meals to 50%.
  2. Updates strings used throughout the application to be appropriate for this school year.
  3. Checks for a fourth criteria (whether teacher has attended Q4 workshop) and provides that check as one of the elements in the "eligibility checklist". Makes model updates to account for this change.
  4. Allows for teachers to get either a full discount code with or without shipping (with shipping codes to be used for Alaska and Hawaii partners). The approach I'm proposing here is that the full_discount flag on CircuitPlaygroundDiscountApplication would be 0 if a teacher is getting a discount code without shipping, and 1 if they are getting one with shipping (this may be inconsistent with last year, if "full discount" discount codes last year were without shipping).
  5. Updates "Unit 6 Validation" step to language specified by Programs team.
  6. Updates appropriate tests to account for changes.

Known issues:
Need to add tests to account for new features (namely, check on attendance at Q4 workshop).

Links

Testing story

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@bencodeorg bencodeorg requested a review from a team as a code owner November 27, 2019 20:04
@bencodeorg bencodeorg changed the base branch from staging to staging-next December 6, 2019 18:13
@bencodeorg
Copy link
Contributor Author

bencodeorg commented Dec 11, 2019

@islemaster before I make some changes to allow this to work correctly for AK/HI teachers, could use your two cents on this point:

4. Allows for teachers to get either a full discount code with or without shipping (with shipping codes to be used for Alaska and Hawaii partners). The approach I'm proposing here is that the full_discount flag on CircuitPlaygroundDiscountApplication would be 0 if a teacher is getting a discount code without shipping, and 1 if they are getting one with shipping (this I think is inconsistent with last year, if "full discount" discount codes last year were without shipping).

Do you care if there's inconsistency there in whether this year full discount (without shipping) is represented as 0 for full_discount, and last year was represented as 1?

I could change the column type and make it something like this, but it would be nice to keep it as a boolean, methinks.

@islemaster
Copy link
Contributor

I'm not worried about year-over-year inconsistency at all, as long as we think it's documented and understandable for someone to revisit next year. IMO full_discount meaning "with shipping" makes sense in isolation and would be fine. All codes for previous years expire on December 31st and I don't feel any need to keep the code for them in a working state.

@bencodeorg
Copy link
Contributor Author

@islemaster I dug in a bit this morning, and I'm worried that the 0/1 full_discount is too intertwined with the idea of whether a school meets the "maker high needs" bar. For example, we set the full_discount value initially based on the teacher's school characteristics. As a result, a teacher who meets the high needs bar would also have full_discount set to 1, making them eligible for the "with shipping" codes in the approach I suggested ^^^.

The options I see are:

  1. (more work) Separate the idea of full_discount from the idea of school_eligibility.
  2. (less work, but maybe too hacky) Keep full discount codes (no shipping) as full_discount = 1 (the case that most teachers will face). Make discount codes with shipping as full_discount = 0. Only admins would be able to get teachers into this state.

I'm leaning towards option 2. Thoughts?

@islemaster
Copy link
Contributor

I'd still lean toward option 1. I don't think we read full_discount anywhere to determine whether a teacher is eligible to receive a code at all. We set it there based on some old logic, but I think we could update that one line to initially set it based on the school's state instead, without breaking anything else.

Happy to sit down and look at this together tomorrow, if you'd like.

@@ -72,7 +73,7 @@ export default storybook => {
)
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add stories to this file for the scenario where the academic year PD requirement has not been passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -54,11 +53,11 @@ def self.find_by_studio_person_id(studio_person_id)
end

# @return {boolean} true if user is an eligible facilitator or attended relevant workshop
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this doc comment to explain the new workshop_subjects parameter.

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 -- I'm not familiar with YARD yet (which is looks like is what we use for our docs?), so hopefully this is syntactically ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Seems fine. We're not actually generating these docs, so syntax errors in YARD are not a big deal right now.

@@ -54,11 +53,11 @@ def self.find_by_studio_person_id(studio_person_id)
end

# @return {boolean} true if user is an eligible facilitator or attended relevant workshop
def self.user_pd_eligible?(user)
user_pd_eligible_as_teacher?(user) || user_pd_eligible_as_facilitator?(user)
def self.user_pd_eligible?(user, workshop_subjects=nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you choose a nil default for this parameter? That passes through to the query below and would match workshops with a NULL subject, which doesn't make sense to me as a default. If it's possible to simply remove the default and require this parameter, I'd prefer that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it nil by default so you could still pass in a facilitator's user ID and get a returned value of true, something like this.

I didn't consider the impact of matching a workshop with a null subject though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did a quick scan and it looks like we don't ever call this method without a second argument in production code, only in test code. Let's remove the default value and any tests covering that behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good -- for the record, I think the link I put here wasn't to the right test, more like the one titled "studio_person_pd_eligible? returns true if studio_person_id associated User is approved facilitator" is relevant.

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 -- I kept most tests for facilitators in place, just added the 5-day workshop as the workshop_subjects argument. I think this tests what we'd see in the wild (facilitators going through the normal flow with no enrollments associated with their accounts, but with their user ID in the list of facilitators).

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Great!

@@ -111,13 +112,25 @@ def self.application_status(user)
has_confirmed_school: application.try(:has_confirmed_school?) || false,
school_id: school_id,
school_name: school_id ? School.find(school_id).name : nil,
school_high_needs_eligible: School.find(school_id).try(:maker_high_needs?),
Copy link
Contributor

Choose a reason for hiding this comment

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

I liked your proposal to move the maker_high_needs? implementation out of the School model and into this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we could create a policy object, a clean-architecture Ruby pattern @Hamms introduced into our project this year.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this as-is for now -- could fix after break if we want.

Pd::Workshop::SUBJECT_CSD_WORKSHOP_6,
Pd::Workshop::SUBJECT_CSD_VIRTUAL_8
]
),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can deduplicate these 12 lines with the matching ones in self.application_status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put together a functional approach to to this (create a method that takes a user and creates a two element hash with keys is_pd_eligible and is_quarterly_workshop_pd_eligible, then merge that hash with the one created here). It seemed kind of funky / confusing though, is there a cleaner way to do that?

@islemaster
Copy link
Contributor

I think this is really close! Great work on this Ben. Once you've got the new full-discount logic done, I've got a few additional notes (above) to address.

As follow-up work, after we merge this PR, we should ask whether the "everyone" discount code that is hard-coded into the system is still active this year, and whether we need that list of eligible facilitators at all (or if we can just remove that code).

After all that, it might be interesting/useful to review the similar update to discount codes last year (#26382) and some fixes that happened not long after (#26823).

Co-Authored-By: Brad Buchanan <brad@code.org>
Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

This looks great Ben! Next steps:

  1. Let's go ahead and change the base branch for this PR to staging now that it's open again.
  2. Let's make sure we get a passing Drone run after the base branch change.
  3. I think we can merge this in before break, and do the new changes Amy brought to our attention in a follow-up PR before we re-enable this feature in January.

Thanks for all the attention to detail on this!

@bencodeorg
Copy link
Contributor Author

Sounds good, going to shoot to clean this up by EOD tomorrow.

@bencodeorg bencodeorg changed the base branch from staging-next to staging December 17, 2019 21:58
@bencodeorg bencodeorg changed the title [WIP] Update circuit playground discount codes Update circuit playground discount code applications for 2020 Dec 17, 2019
@bencodeorg bencodeorg merged commit dba7401 into staging Dec 21, 2019
@bencodeorg bencodeorg deleted the update-circuit-playground-discount-codes branch December 21, 2019 01:19
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.

None yet

2 participants