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

Refactor model to split eligibility from benefit #90

Closed
thekaveman opened this issue Jun 17, 2021 · 1 comment
Closed

Refactor model to split eligibility from benefit #90

thekaveman opened this issue Jun 17, 2021 · 1 comment
Labels
back-end Django views, sessions, middleware, models, migrations etc.

Comments

@thekaveman
Copy link
Member

The EligibilityType model contains two properties used by different phases of the system:

  • EligibilityType.name is used in the eligibility phase as part of the API call to verify
  • EligibilityType.group_id is used in the enrollment phase as the group to enroll eligible users into

However, as noted and fixed in #89, we may have multiple EligiblityType with the same name and different group_id. For example, a senior type for each transit agency, each with a different group_id.

The fix in #89 was somewhat of a hack, as these concerns could (should?) be split out to allow reusing EligibilityType instances. Thinking of a refactor along the lines of:

Before

class EligibilityType(models.Model):
    """Currently used for both eligibility and enrollment"""
    name = models.TextField()
    label = models.TextField()
    group_id = models.TextField()

class TransitAgency(models.Model):
   # other fields ...
    eligibility_types = models.ManyToManyField(EligibilityType)

After

class EligibilityType(models.Model):
    """Used for eligibility checks - reused across agencies"""
    name = models.TextField()
    label = models.TextField()

class BenefitGroup(models.Model):
    """Used for enrollment - at least one per agency"""
    name = models.TextField()
    group_id = models.TextField()
    eligibility_type = models.ForeignKey(EligibilityType, on_delete=models.PROTECT)

class TransitAgency(models.Model):
   # other fields ...
   benefit_groups = models.ManyToManyField(BenefitGroup)
@thekaveman thekaveman modified the milestone: August 2021 Aug 23, 2021
@thekaveman thekaveman added this to the November 2021 milestone Oct 15, 2021
@thekaveman thekaveman modified the milestones: December 2021, January 2022, January 2022 maintenance, Courtesy Cards Jan 4, 2022
@thekaveman thekaveman moved this to Backlog in Digital Services Jan 21, 2022
@thekaveman thekaveman removed this from the Courtesy Cards milestone Mar 15, 2022
@thekaveman thekaveman added back-end Django views, sessions, middleware, models, migrations etc. and removed models labels Jun 16, 2022
@thekaveman
Copy link
Member Author

Closing for now. This data model / relationship hasn't been a blocker, and the issue is creating noise on the backlog. Revisit in the future if needed.

Repository owner moved this from Backlog to Done in Digital Services Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc.
Projects
Archived in project
Development

No branches or pull requests

1 participant