def compare_usage_metrics()

in source/ecs/workspaces_helper.py [0:0]


    def compare_usage_metrics(self, workspace_id, billable_time, hourly_threshold, workspace_running_mode):
        """
        This method compares the usage metrics for the workspace
        :param workspace_id: workspace id
        :param billable_time: billable time
        :param hourly_threshold: hourly threshold for the bundle type
        :param workspace_running_mode: new running mode
        :return: The result code and the new running mode for the workspace
        """
        if billable_time is None:
            result_code = '-E-'
            new_mode = workspace_running_mode
        elif hourly_threshold is None:
            result_code = '-S-'
            new_mode = workspace_running_mode
        elif workspace_running_mode == AUTO_STOP:
            result_code, new_mode = self.compare_usage_metrics_for_auto_stop(workspace_id, billable_time,
                                                                             hourly_threshold, workspace_running_mode)
        elif workspace_running_mode == ALWAYS_ON:
            result_code, new_mode = self.compare_usage_metrics_for_always_on(workspace_id, billable_time,
                                                                             hourly_threshold, workspace_running_mode)
        else:
            log.error(
                'workspaceRunningMode {} is unrecognized for workspace {}'.format(workspace_running_mode, workspace_id))
            result_code = '-S-'
            new_mode = workspace_running_mode

        return {
            'resultCode': result_code,
            'newMode': new_mode
        }