Repository: locustio/locust
File: locust/web.py (Python)

Code before:
            worker_count = 0

        stats = self.environment.runner.stats
        extra_options = argument_parser.ui_extra_args_dict()

        available_user_classes = (
            None if not self.environment.available_user_classes else sorted(self.environment.available_user_classes)
        )

        available_shape_classes = ["Default"]
        if self.environment.available_shape_classes:
            available_shape_classes += sorted(self.environment.available_shape_classes.keys())

        if self.modern_ui:
            percentiles = {
                "percentiles_to_chart": stats_module.MODERN_UI_PERCENTILES_TO_CHART,
                "percentiles_to_statistics": stats_module.PERCENTILES_TO_STATISTICS,
            }
        else:
            percentiles = {
                "percentile1": stats_module.PERCENTILES_TO_CHART[0],
                "percentile2": stats_module.PERCENTILES_TO_CHART[1],
                # Convert percentiles to percent notation for use in templates
                "percentiles_to_statistics": [
                    normalize_decimal(percentile * 100) for percentile in stats_module.PERCENTILES_TO_STATISTICS
                ],
            }

        self.template_args = {
            "locustfile": self.environment.locustfile,
            "state": self.environment.runner.state,
            "is_distributed": is_distributed,
            "user_count": self.environment.runner.user_count,
            "version": version,
            "host": host if host else "",
            "history": stats.history if stats.num_requests > 0 else {},
            "override_host_warning": override_host_warning,
            "num_users": options and options.num_users,
            "spawn_rate": options and options.spawn_rate,
            "worker_count": worker_count,
            "hide_common_options": (
                self.environment.shape_class
                and not (self.userclass_picker_is_active or self.environment.shape_class.use_common_options)
            ),
            "stats_history_enabled": options and options.stats_history_enabled,
            "tasks": dumps({}),
            "extra_options": extra_options,
            "run_time": options and options.run_time,
            "show_userclass_picker": self.userclass_picker_is_active,
            "available_user_classes": available_user_classes,
            "available_shape_classes": available_shape_classes,

Review comment (suggestion):
I think we shouldn't have to support any new features on the legacy UI. We could leave this as is and then we wouldn't need to change the templating

Code after:

        stats = self.environment.runner.stats
        extra_options = argument_parser.ui_extra_args_dict()

        available_user_classes = (
            None if not self.environment.available_user_classes else sorted(self.environment.available_user_classes)
        )

        available_shape_classes = ["Default"]
        if self.environment.available_shape_classes:
            available_shape_classes += sorted(self.environment.available_shape_classes.keys())

        if self.modern_ui:
            percentiles = {
                "percentiles_to_chart": stats_module.MODERN_UI_PERCENTILES_TO_CHART,
                "percentiles_to_statistics": stats_module.PERCENTILES_TO_STATISTICS,
            }
        else:
            percentiles = {
                "percentile1": stats_module.PERCENTILES_TO_CHART[0],
                "percentile2": stats_module.PERCENTILES_TO_CHART[1],
            }

        self.template_args = {
            "locustfile": self.environment.locustfile,
            "state": self.environment.runner.state,
            "is_distributed": is_distributed,
            "user_count": self.environment.runner.user_count,
            "version": version,
            "host": host if host else "",
            "history": stats.history if stats.num_requests > 0 else {},
            "override_host_warning": override_host_warning,
            "num_users": options and options.num_users,
            "spawn_rate": options and options.spawn_rate,
            "worker_count": worker_count,
            "hide_common_options": (
                self.environment.shape_class
                and not (self.userclass_picker_is_active or self.environment.shape_class.use_common_options)
            ),
            "stats_history_enabled": options and options.stats_history_enabled,
            "tasks": dumps({}),
            "extra_options": extra_options,
            "run_time": options and options.run_time,
            "show_userclass_picker": self.userclass_picker_is_active,
            "available_user_classes": available_user_classes,
            "available_shape_classes": available_shape_classes,
            **percentiles,
        }

    def _update_shape_class(self, shape_class_name):
        if shape_class_name: