At the weekend an issue was discovered where the displayed review status of a table was apparently not updated after changing it (e.g. from "Todo" to "Passed") and refreshing the page (done automatically when clicking "Approve All Tables"). I resolved the issue for now by switching off Cloudflare caching. However, it would be good to fix the issue in the HEPData code such that we can turn Cloudflare caching back on to improve performance.
The issue arose because the endpoint /record/data/<int:recid>/<int:data_recid>/<int:version>/ was cached by Cloudflare. It contains code that writes the table review status (and whether the table has review messages) to the table JSON:
|
table_contents["review"] = {} |
|
|
|
data_review_record = create_data_review(data_recid, recid, version) |
|
table_contents["review"]["review_flag"] = data_review_record.status if data_review_record else "todo" |
|
table_contents["review"]["messages"] = len(data_review_record.messages) > 0 if data_review_record else False |
This information is used for the front-end rendering in table_list.html:
|
<span id="{{ table.id }}-status" class="review-status {{ table.review_flag }}"> |
|
<span id="icon" |
|
class="fa fa-{% if table.review_flag == 'attention' %}exclamation-triangle {% elif table.review_flag == 'passed' %}check-circle{% else %}exclamation-triangle{% endif %}"></span> |
|
<span class="text">{{ table.review_status }}</span> |
|
</span> |
|
|
|
<span id="table-{{ table.id }}-messages" |
|
class="messages {% if not table.messages %} hidden{% endif %}"> |
|
<span class="fa fa-comment"></span> |
|
</span> |
and in hepdata_tables.js:
|
HEPDATA.update_review_statuses(review_info.review_flag); |
An alternative way of getting this information without relying on /record/data/<int:recid>/<int:data_recid>/<int:version>/ should be implemented, perhaps by using the existing /record/data/review/status/ and /record/data/review/message/<int:data_recid>/<int:version> endpoints, or better, to add a new endpoint getting exactly the information needed. By the way, it looks like the endpoints /record/data/review/ and /record/data/review/status/ are missing a @login_required decorator.
@ItIsJordan : can you please try to address this issue? (Or assign it to Copilot and test/review the proposed changes.)
At the weekend an issue was discovered where the displayed review status of a table was apparently not updated after changing it (e.g. from "Todo" to "Passed") and refreshing the page (done automatically when clicking "Approve All Tables"). I resolved the issue for now by switching off Cloudflare caching. However, it would be good to fix the issue in the HEPData code such that we can turn Cloudflare caching back on to improve performance.
The issue arose because the endpoint
/record/data/<int:recid>/<int:data_recid>/<int:version>/was cached by Cloudflare. It contains code that writes the table review status (and whether the table has review messages) to the table JSON:hepdata/hepdata/modules/records/views.py
Lines 400 to 404 in 5621751
This information is used for the front-end rendering in
table_list.html:hepdata/hepdata/modules/records/templates/hepdata_records/components/table_list.html
Lines 135 to 144 in 5621751
and in
hepdata_tables.js:hepdata/hepdata/modules/records/assets/js/hepdata_tables.js
Line 316 in 5621751
An alternative way of getting this information without relying on
/record/data/<int:recid>/<int:data_recid>/<int:version>/should be implemented, perhaps by using the existing/record/data/review/status/and/record/data/review/message/<int:data_recid>/<int:version>endpoints, or better, to add a new endpoint getting exactly the information needed. By the way, it looks like the endpoints/record/data/review/and/record/data/review/status/are missing a@login_requireddecorator.@ItIsJordan : can you please try to address this issue? (Or assign it to Copilot and test/review the proposed changes.)