Closed netnazgul closed 6 years ago
another issue this pr fixes is that maps that were reported >2 times will have big red "ATTENTION" banner even if they don't have active reports. amount_reports
is used in html checks whereas in python code Reports
container is polled like this:
https://github.com/OpenRA/OpenRA-Resources/blob/6f601d98ad0fe5c3adfc98d14a420db50dbaa5b8/openra/api.py#L237-L238
I was able to reproduce the original problem, and this fix works fine for me.
I guess ideally the hard coded amount_reports variable shouldn't exist, and a proper relationship should be set up between Maps and Reports, but that would involve a lot more changes, and this fixes the problem (other than updating the database).
Also with regards to updating existing records, does this SQL look ok:
UPDATE openra_maps
SET amount_reports = (
SELECT COUNT(*) FROM openra_reports WHERE ex_id = openra_maps.id
);
I tested it on my local version and it updated correctly there, but I thought I should post it here too to check in case there is something I've missed.
Ok, this has now been deployed and the SQL above run.
Supposedly fixes #306
If it works, existing maps with incorrect non-zero "amount_reports" attribute need to be updated manually in the database.