mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
0847a395dc
Creates a new project read model exposing data to be used for the UI and for the insights module. The model contains two public methods, both based on the project store's `getProjectsWithCounts`: - `getProjectsForAdminUi` - `getProjectsForInsights` This mirrors the two places where the base query is actually in use today and adapts the query to those two explicit cases. The new `getProjectsForAdminUi` method also contains data for last flag update and last flag metric reported, as required for the new projects list screen. Additionally the read model contains a private `getMembersCount` method, which is also lifted from the project store. This method was only used in the old `getProjectsWithCounts` method, so I have also removed the method from the public interface. This PR does *not* hook up the new read model to anything or delete any existing uses of the old method. ## Why? As mentioned in the background, this query is used in two places, both to get data for the UI (directly or indirectly). This is consistent with the principles laid out in our [ADR on read vs write models](https://docs.getunleash.io/contributing/ADRs/back-end/write-model-vs-read-models). There is an argument to be made, however, that the insights module uses this as an **internal** read model, but the description of an internal model ("Internal read models are typically narrowly focused on answering one question and usually require simple queries compared to external read models") does not apply here. It's closer to the description of external read models: "View model will typically join data across a few DB tables" for display in the UI. ## Discussion points ### What about properties on the schema that are now gone? The `project-schema`, which is delivered to the UI through the `getProjects` endpoint (and nowhere else, it seems), describes properties that will no longer be sent to the front end, including `defaultStickiness`, `avgTimeToProduction`, and more. Can we just stop sending them or is that a breaking change? The schema does not define them as required properties, so in theory, not sending them isn't breaking any contracts. We can deprecate the properties and just not populate them anymore. At least that's my thought on it. I'm open to hearing other views. ### Can we add the properties in fewer lines of code? Yes! The [first commit in this PR ( |
||
---|---|---|
.. | ||
lib | ||
mailtemplates | ||
migrations | ||
test | ||
migrator.ts | ||
server-dev.ts | ||
server.ts |