sofie-core icon indicating copy to clipboard operation
sofie-core copied to clipboard

feat: split collections to have server and client versions

Open Julusian opened this issue 1 year ago • 1 comments

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Code quality

  • What is the current behavior? (You can also link to an open issue here)

We have all the mongodb collections defined in meteor/lib/collections. These are then used by both the server and the client. They expose both async and sync methods, even though we only want to use sync methods on the client (for now), and async methods on the server (to prepare for removal of fibers). in shared code, we need to decide on a strategy.

  • What is the new behavior (if this is a feature change)?

By splitting the collection object so that each of the server and client have their own versions. This will let us control what methods are available in each place separately, and continue to identify and remove usages of the sync methods on the server collections. (We don't need to rush to do this, but it will be needed for Meteor 2.11)

Some collections are not being published to the client, and this isolation allows us to see that more clearly as we can skip defining those client versions.

For now the client collections reside in meteor/lib, so that the shared code in lib can use them. We will likely want to move them eventually, but that will be a much smaller and easier change.
It currently looks a bit unclear as to whether the sync methods will be usable on the client in later versions of meteor, so in the future these may need to become async too, but this lets us approach that independently to the server side.

Minimongo is fine with these being defined like this, any 'collections' used by custom publications have their definitions scattered somewhere in the ui code for a while.

  • Other information:

So far this is prototyped on a couple of collections, to allow for evaluating how it looks and whether to progress on it.

Most of this change is updating imports. The files containing the new definitions are of the most interest:

  • https://github.com/nrkno/sofie-core/blob/feat/seperate-server-client-collections/meteor/server/serverCollections.ts
  • https://github.com/nrkno/sofie-core/blob/feat/seperate-server-client-collections/meteor/lib/clientCollections.ts These could be broken out to more files if necessary. I am not sure that either will get long enough to justify it.

This allows us to remove a lot of the meteor/lib/collections/* files, as most of them are simply re-exporting types that moved to corelib a while ago as well as defining the collections which are being moved as part of this.

There is an object containing all of the collections currently. I think this will not be necessary in the future, so can be removed, or at least refactored. It is being broken by this change so far

Status

  • [ ] Code documentation for the relevant parts in the code have been added/updated by the PR author
  • [ ] The functionality has been tested by the PR author
  • [ ] The functionality has been tested by NRK

Julusian avatar Sep 30 '22 14:09 Julusian

Codecov Report

Base: 68.09% // Head: 72.51% // Increases project coverage by +4.41% :tada:

Coverage data is based on head (32e9c43) compared to base (875e9ee). Patch has no changes to coverable lines.

Additional details and impacted files
@@              Coverage Diff              @@
##           release47     #768      +/-   ##
=============================================
+ Coverage      68.09%   72.51%   +4.41%     
=============================================
  Files            278       97     -181     
  Lines          34706    24784    -9922     
  Branches        4639     2386    -2253     
=============================================
- Hits           23634    17971    -5663     
+ Misses         10631     6782    -3849     
+ Partials         441       31     -410     
Impacted Files Coverage Δ
meteor/lib/api/pubsub.ts
meteor/lib/collections/RundownPlaylists.ts
meteor/lib/collections/Rundowns.ts
meteor/lib/collections/Workers.ts
meteor/lib/collections/lib.ts
meteor/lib/collections/optimizations.ts
meteor/lib/main.ts
meteor/server/api/blueprints/api.ts
meteor/server/api/buckets.ts
meteor/server/api/cleanup.ts
... and 162 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Oct 20 '22 17:10 codecov-commenter