Implement Providers in "upcoming" script #250
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Providers for the dates of upcoming launches
Introduction
This PR implements a new structure for the "upcoming" script that simplifies and facilitates the implementation of additional sources of information for the launch date, when the launch is within a specified threshold. I've called each source of information for the script, a "provider". The goal is to make it easier to implement other providers in the future, like trusted users and Twitter scraping, into the calculation of the dates of upcoming launches.
Details & Motivation
In order to:
The two current providers of launch dates, the main code for retrieving and processing, both the wiki manifest and the data from the Launch Library API, have been separated into different files, leaving in the "upcoming" script mostly the logic merging the dates from both sources and update the database.
With this implementation it should be far less complicated and cumbersome to implement other providers. Also it makes the main script more readable and shorter.
There was a bug in my previous implementation, which calculated wrongly the last update time of the wiki, it used the last time the API fetched the manifest, which was an inaccurate measurement.
The new code relies instead on the history of revisions of the wiki, available here, and keeps track of the UUID of the revision and actually compares the stored launch date and the new launch date in the manifest, to see if it changed.
Finally, the new fields required to make the new code work will only be added to the launch document in the database once it is within the threshold, so it will not alter any launch until it is close enough.
Changes in the database
New Fields
Here are the new fields for the launches (Only added when the launch enters the threshold).
Wiki provider
LL provider
General
Fields that have to be removed manually
And these are the fields, added by the old code, that should be removed from the live database because they are replaced and improved by the new ones: