MDL-46576 core_grades: MDL-47006 Refactor weightings code for readibility