<commit_before>/******************************************
* Requests Collection
*/
app.Collections.Requests = app.Collections.GenericCollection.extend({

	model        : app.Models.Request,

	url          : '/api/openstc/intervention_requests',

	fields       : ["id", "name", "actions", "tooltip", "create_date", "create_uid", "date_deadline", "description", "manager_id", "note", "partner_address", "partner_id", "partner_phone", "partner_service_id", "partner_type", "partner_type_code", "people_name", "people_email", "people_phone", "refusal_reason", "service_id", "site1", "site_details", "state"],

	// Model name in the database //
	model_name   : 'openstc.ask',

	default_sort : { by: 'id', order: 'DESC' },


	/** Collection Initialization
	*/
	initialize: function (options) {
		//console.log('Requests collection Initialization');
	},
	
	//override to customize method for this collection
	specialCount: function(modelName){
		var self = this;
		
		//to keep value of cpt, because count method override this value at each call
		var cptSave = self.cpt;
		
		//construct a domain accrding to user group
		var domain = {};
		if(app.models.user.isDST()){
			domain = {'field':'state','operator':'=','value':'confirm'};
		}
		else if(app.models.user.isManager()){
			domain = {'field':'state','operator':'=','value':'wait'};
		}
		//use count method to retrieve values according to domain
		$.when(
			self.count({search: app.objectifyFilters([domain])})
		)
		.done(function(){
			self.specialCpt = self.cpt;
			self.cpt = cptSave;
		})
		
	},
	
	/** Collection Sync
	*/
	sync: function(method, model, options){<commit_msg>updated RequestCollection Sync to use new format of count method<commit_after>/******************************************
* Requests Collection
*/
app.Collections.Requests = app.Collections.GenericCollection.extend({

	model        : app.Models.Request,

	url          : '/api/openstc/intervention_requests',

	fields       : ["id", "name", "actions", "tooltip", "create_date", "create_uid", "date_deadline", "description", "manager_id", "note", "partner_address", "partner_id", "partner_phone", "partner_service_id", "partner_type", "partner_type_code", "people_name", "people_email", "people_phone", "refusal_reason", "service_id", "site1", "site_details", "state"],

	// Model name in the database //
	model_name   : 'openstc.ask',

	default_sort : { by: 'id', order: 'DESC' },


	/** Collection Initialization
	*/
	initialize: function (options) {
		//console.log('Requests collection Initialization');
	},
	
	//override to customize method for this collection
	specialCount: function(modelName){
		var self = this;
		
		//to keep value of cpt, because count method override this value at each call
		var cptSave = self.cpt;
		
		//construct a domain accrding to user group
		var domain = {};
		if(app.models.user.isDST()){
			domain = {'field':'state','operator':'=','value':'confirm'};
		}
		else if(app.models.user.isManager()){
			domain = {'field':'state','operator':'=','value':'wait'};
		}
		//use count method to retrieve values according to domain
		$.when(
			self.count({data: {filters: app.objectifyFilters([domain])}})
		)
		.done(function(){
			self.specialCpt = self.cpt;
			self.cpt = cptSave;
		})
		
	},
	
	/** Collection Sync
	*/
	sync: function(method, model, options){
{'fraction_non_alphanumeric': 0.18610944076969332, 'fraction_numerical': 0.0006013229104028864, 'mean_word_length': 4.392220421393841, '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': '2631480', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1022, 'n_words': 253}