guardian / typerighter

Even if you’re the right typer, couldn’t hurt to use Typerighter!
Apache License 2.0
276 stars 12 forks source link

Add live and draft rule-tag join tables #333

Closed rhystmills closed 1 year ago

rhystmills commented 1 year ago

What does this change?

Follow-up to https://github.com/guardian/typerighter/pull/330

Adds join tables for tags and rules, modelling the many-to-many relationships between the two. These relationships will have a live and draft state, modelled in separate live and draft tables.

This PR only adds:

It does not add routes for managing tag-rule relationships (e.g. endpoints for adding/removing tags to/from rules) or a UI, which will be added in follow-up PRs in order to keep this one simple.

How to test

  1. Run the application locally (./script.start)
  2. Run the tests (sbt test). Do they all pass?
jonathonherbert commented 1 year ago

Just a general comment, as there's some repetition in this PR – have you explored a way of sharing code between tables? I wonder if it might be possible to encapsulate common functionality in a trait, and leave the things that are not common (table name, syntax) to the inheriting objects?

rhystmills commented 1 year ago

Just a general comment, as there's some repetition in this PR – have you explored a way of sharing code between tables? I wonder if it might be possible to encapsulate common functionality in a trait, and leave the things that are not common (table name, syntax) to the inheriting objects?

I wasn't quite sure how to do it but you have compelled me to figure it out, looking much better now!