<commit_before>
(function () {

openerp.web_graph.PivotTable = openerp.web.Class.extend({
	id_seed: 0,

	init: function (options) {
		main_row = {
			id: this.generate_id(),
			path: [],
			title: "Total",
			is_expanded: false,
			parent: null,
			children: [],
			domain: options.domain,
		};
		main_col = {
			id: this.generate_id(),
			path: [],
			title: options.measure_label,
			is_expanded: false,
			parent: null,
			children: [],
			domain: options.domain,
		};

		this.rows = {
			groupby: options.row_groupby,
			main: main_row,
			headers: [main_row],
		};
		this.cols = {
			groupby: [],
			main: main_col,
			headers: [main_col],
		};

		main_row.root = this.rows;
		main_col.root = this.cols;
		this.cells = [];
		this.model = options.model;
		this.domain = options.domain;
		this.measure = options.measure;
		this.measure_label = options.measure_label;
		this.total = 0;
	},

	// Load initial data into the rows, cols and cells array.
	// This function needs to be called after init and before
	// drawing the table (otherwise the data returned will be empty...)
	start: function () {
		var self = this,
			initial_group = this.expand(this.rows.main.id, this.rows.groupby[0]),
			total = query_groups(this.model, this.measure, this.domain, [])
				.then(function (total) {
					var val = total[0].attributes.aggregates[self.measure];
					self.set_value(self.rows.main.id, self.cols.main.id, val);
					self.total = val;
				});

		return $.when(total, initial_group);
	},

	generate_id: function () {
		this.id_seed += 1;
		return this.id_seed;
	},

	visible_fields: function () {
		return this.rows.groupby.concat(this.cols.groupby, this.measure);<commit_msg>[REF] simplify the start() method in pivot table by using the expand_all() method instead of manually loading data (addon web_graph)<commit_after>
(function () {

openerp.web_graph.PivotTable = openerp.web.Class.extend({
	id_seed: 0,

	init: function (options) {
		main_row = {
			id: this.generate_id(),
			path: [],
			title: "Total",
			is_expanded: false,
			parent: null,
			children: [],
			domain: options.domain,
		};
		main_col = {
			id: this.generate_id(),
			path: [],
			title: options.measure_label,
			is_expanded: false,
			parent: null,
			children: [],
			domain: options.domain,
		};

		this.rows = {
			groupby: options.row_groupby,
			main: main_row,
			headers: [main_row],
		};
		this.cols = {
			groupby: [],
			main: main_col,
			headers: [main_col],
		};

		main_row.root = this.rows;
		main_col.root = this.cols;
		this.cells = [];
		this.model = options.model;
		this.domain = options.domain;
		this.measure = options.measure;
		this.measure_label = options.measure_label;
		this.total = 0;
	},

	start: function () {
		return this.expand_all();
	},

	generate_id: function () {
		this.id_seed += 1;
		return this.id_seed;
	},

	visible_fields: function () {
		return this.rows.groupby.concat(this.cols.groupby, this.measure);
{'fraction_non_alphanumeric': 0.1469986357435198, 'fraction_numerical': 0.002728512960436562, 'mean_word_length': 3.288011695906433, 'pattern_counts': {'":': 0, '<': 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': '5549488', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1028, 'n_words': 225}