virtUOS / edusharing-opencast-importer

This importer harvests episodes (lecture recordings) from Opencast instances and push it as external references to an Edusharing instance.
GNU General Public License v3.0
2 stars 2 forks source link

code review suggestions #21

Closed jduehring closed 3 years ago

jduehring commented 3 years ago

See Update

Regarding #17: There are a few noteworthy small changes that might improve overall code quality.

  1. When starting the program for the first time, the data directory would not be created. Instead an error was thrown and one had to manually create it. Now the folder will be created automatically.

  2. In harvestOcInstance.js the initStoredData does not load the data in an asynchronous manner. We could use await Promise.all(...) to change that

  3. There are two cases throughout the codebase in which a new Promise(....) is explicitly created inside an asynch function. In my opinion, since an asynch function will always wrap the result/error in a promise, it would be better to restrain calling of new Promise(....). This leads to better readability, uses the advantage of asynch functions and prevents forgetting to explicitly resolve() or reject() given promise. I exemplary changed the storeData() function in data-storage.js.

  4. Regarding Error-Handling (#19 ): Besides refining a few error-messages, there currently is a bug that we ignore an thrown error, when trying to create an existing ES-node (#15). I proposed a solution in #20.

UPDATE - Ready for review

Except the known bug from #15, all improvements 1-4 are implemented. In general the program should behave in the same way as before. I added two noteworthy additonal things:

  1. General Error-Handling: I created custom Error classes, that will be thrown in the appropriate cases and that cause fitting Error Messages from the logger. For now i put the js-file in/models/errors.js.

  2. await vs then: Throughout the code a mix of the keywords await and then is used. I believe most of the time, we can simplify the code a lot by only using the await syntax. We should not lose any parallel processes, since in most of these cases we wait for the previous operation to finish anyways. I changed the corresponding code in harvestOcInstance.js. We can probably simplify quite some more code, but I would not prioritize that for now.

--> Code is ready for review and can be merged if approved

ffeyen commented 3 years ago

closes #17 resolves #19