Skip to content

Refactor comparison publication model

Marcel Konrad requested to merge refactor-comparison-publication-model into master

This MR aligns the comparison publication model with the literature list and smart review publication model. Previously, each published comparison was saved in a "hasPreviousVersion" statement chain, indicating the previous version of a comparison. Now, comparisons are stored in a "star" graph, where the center node represents the (unpublished) head version of a comparison, which previously did not exist. All published versions of that comparison are linked via a "hasPublishedVersion" statement. The classes have also been adjusted. Each published version comparison, is now an instance of "ComparisonPublished" and no longer an instance of "Comparison". Furthermore, the latest published version is also an instance of "LatestVersion" for performance reasons.

To migrate the existing database, you need to run the following command:

gradlew runComparisonMigrations

This process takes roughly 6 minutes on my local machine. Don't panic if the application stops with an error message, it is expected, because it is not possible to gracefully stop the application after the migration. As long as it says "Comparison migration complete" somewhere above the error message, everything worked as expected. The script duplicates the latest published comparison version, to create the current head version. Then, all "hasPreviousVersion" statements are converted to "hasPublishedVersion" statements. The class labels are updated as described in the first paragraph of the MR. All metadata is preserved in the process.

The following endpoints have been modified to accommodate the new model:

Endpoint Comment
/api/comparisons - Now supports filtering by "research_problem".
- Now supports filtering by "published".
- Response field versions now contains a head version.
/api/research-fields/{id}/subfields/comparisons Returns published (latest only) and unpublished comparisons. Should be replaced with /api/comparisons
/api/research-fields/{id}/comparisons Returns published (latest only) and unpublished comparisons. Should be replaced with /api/comparisons
/api/comparisons/{id}/authors Context: This endpoint returns the top authors of related papers. Behaviour should be identical.
/api/problems/{id}?classes=Comparison Only returns published (latest & outdated) comparisons, previously all. Should be replaced with /api/comparisons if queried only for comparisons.
/api/stats/{id}/stats/comparisons Only returns latest published comparisons, previously all.
/api/stats/observatories Only counts latest published comparisons, previously all.
/api/stats/research-fields/{id} Only counts latest published comparisons, previously all.
/api/stats/observatories/{id} Only counts latest published comparisons, previously all.
/api/stats/top/contributors Only counts published comparisons, previously all.
/api/stats/research-field/{id}/top/contributors Only counts published comparisons, previously all.
/api/stats/top/changelog Only counts published comparisons, previously all.
/api/stats/research-field/{id}/top/changelog Only counts published comparisons, previously all.
/api/content-types Only returns published comparisons, previously all.

A merge and release needs to be synchronized with the front-end team! Review should be easy when going through individual commits.

Edited by Marcel Konrad

Merge request reports