human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Change agency_type to a Rails enum

Open dorner opened this issue 10 months ago • 9 comments

Summary

There are a number of tests that check PartnerProfile#agency_type against a string "Other". Some other tests check the value in an array instead:

Partner::AGENCY_TYPES['OTHER']

This seems to be hiding a hidden issue, which is that this field really should be an enum. We don't need to go all the way to defining a Postgres enum; we can just turn the field into a Rails enum as documented here.

Things to consider

A bonus to this would be moving the AGENCY_TYPES map from the Partner class to the PartnerProfile class, as that's where it's actually used.

Criteria for Completion

  • [] Agency type is a Rails enum.
  • Specs are updated to query e.g. profile.other? instead of checking against any specific string value.
  • All other functionality still works as expected.

dorner avatar Mar 31 '24 14:03 dorner

I'd like to pick this issue up.

veezus avatar Apr 01 '24 14:04 veezus

Go for it!

dorner avatar Apr 01 '24 16:04 dorner

It looks like we're currently storing the agency type description string in the database (not the code). Do we want, as part of this PR, a migration to convert agency types from, for example, Government Agency/Affiliate to GOVT?

veezus avatar Apr 01 '24 19:04 veezus

Hmm... that's a good question. I think it's definitely a better approach than storing the full string. We'd have to be very careful about the rollout, though.

I think we'd have to do something like allowing both long and short values in the enum hash, then doing the migration, then removing the long values from the hash.

dorner avatar Apr 02 '24 14:04 dorner

This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.

github-actions[bot] avatar May 03 '24 00:05 github-actions[bot]

We're just waiting on a data cleanup (#4261) before we move forward on this one.

veezus avatar May 03 '24 11:05 veezus

Automatically unassigned after 7 days of inactivity.

github-actions[bot] avatar May 11 '24 00:05 github-actions[bot]

NDBN sent me back some stuff, but I need to review it -- probably a Monday job at this point.

cielf avatar May 11 '24 01:05 cielf

I had provided the requested mapping on #4261 but it hasn't been finished. That would be the next step on this.

cielf avatar Oct 11 '24 18:10 cielf