<commit_before>var Config = require('../../config')
var RestClient = require('node-rest-client').Client
var _ = require('underscore')
var Backbone = require('backbone')
Backbone.$ = require('jquery')

var TasksUri = 'http://' + Config.marathon.host + ':' + Config.marathon.port + '/v2/tasks'
var Task = Backbone.Model.extend({})
var Tasks = Backbone.Collection.extend({
	model: Task,
	url: TasksUri,
	parse: function(response) {
		var tasks = {}
		_.each(response.tasks, function(task) {
			if(task.ports) {
				_.each(task.servicePorts, function(port, idx) {
					var id = (task.appId + '_' + port.toString()).replace(/^\//, '').replace(/[^\w]/g, '_')
					if(!tasks.hasOwnProperty(id)) {
						tasks[id] = {
							id: id,
							port: port,
							appId: task.appId,		
							hosts: [],
							settings: {
								options: []
							}
						}
					}
					tasks[id].hosts.push({
						id: (task.host + '_' + task.ports[idx].toString()).replace(/^\//, '').replace(/[^\w]/g, '_'),
						host: task.host,
						port: task.ports[idx]
					})
				})
			}
		})
		return _.toArray(tasks)
	}
})

Tasks.getTasks = function(callback) {
	new RestClient().get(TasksUri, function(data, response) {
		callback(null, new Tasks().parse(data));	
	})
}

module.exports = Tasks;<commit_msg>Updated GET request for tasks to send Accept header for new version of marathon<commit_after>var Config = require('../../config')
var RestClient = require('node-rest-client').Client
var _ = require('underscore')
var Backbone = require('backbone')
Backbone.$ = require('jquery')

var TasksUri = 'http://' + Config.marathon.host + ':' + Config.marathon.port + '/v2/tasks'
var Task = Backbone.Model.extend({})
var Tasks = Backbone.Collection.extend({
	model: Task,
	url: TasksUri,
	parse: function(response) {
		var tasks = {}
		_.each(response.tasks, function(task) {
			if(task.ports) {
				_.each(task.servicePorts, function(port, idx) {
					var id = (task.appId + '_' + port.toString()).replace(/^\//, '').replace(/[^\w]/g, '_')
					if(!tasks.hasOwnProperty(id)) {
						tasks[id] = {
							id: id,
							port: port,
							appId: task.appId,		
							hosts: [],
							settings: {
								options: []
							}
						}
					}
					tasks[id].hosts.push({
						id: (task.host + '_' + task.ports[idx].toString()).replace(/^\//, '').replace(/[^\w]/g, '_'),
						host: task.host,
						port: task.ports[idx]
					})
				})
			}
		})
		return _.toArray(tasks)
	}
})

Tasks.getTasks = function(callback) {
	new RestClient().get(TasksUri, {headers: {"Accept": "application/json"}}, function(data, response) {
		callback(null, new Tasks().parse(data));	
	})
}

module.exports = Tasks;
{'fraction_non_alphanumeric': 0.19962335216572505, 'fraction_numerical': 0.0007532956685499058, 'mean_word_length': 2.940652818991098, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3481446', 'n_tokens_mistral': 1119, 'n_tokens_neox': 904, 'n_words': 169}