These lines should probably be

    Measure.by_user(current_user).each { |m| m.generate_js clear_db_cache: true }

The JS needs to be generated anyway, so adding that work here shouldn't be an issue, plus this is the way the cache is cleared elsewhere.