MDL-68683 competencies: fix query to delete stale files