RADAR-base / RADAR-Questionnaire

Questionnaire mobile application (Active App) for RADAR-base
https://radar-base.org/
Apache License 2.0
18 stars 13 forks source link

Improve and refactor Github client #1318

Open mpgxvii opened 3 years ago

mpgxvii commented 3 years ago

Currently, we have 2 Github fetch strategies from Github:

  1. Default (pulling directly from Github through an unauthenticated HTTP request) and
  2. App Server (making a request to the Appserver which will make an authenticated HTTP request to Github)

However, the current implementation is simple and not easily extensible. In order to have more structure and flexibility, we can:

  1. Have a base class QuestionnaireFetchStrategy with abstract functions getRaw() or just get() and getContent() and any other you think will be useful. Then the concrete classes can be GithubQuestionnaireFetchStrategy and AppSeverQuestionnaireFetchStrategy. So if later we use app-config, you can just add a new class extending this strategy base class. Also, instead of GithubClient, it can be called QuestionnaireFetcher or something like that.

  2. An alternative approach would be to make it specific based on protocol and definitions. So then you can change how each is pulled, then the base class QuestionnaireFetchStrategy can have abstract functions getDefinitions() and getProtocols(). But this will be a bigger refactor.

mpgxvii commented 3 years ago

Personally, I prefer the second approach.