Module("JEDAI.Ranking", function(Ranking) {
	Ranking.fn.initialize = function(container, users) {
		this.container = container;
		this.users     = users;
		this.template  = null;
		this.interval  = null;
	};

	Ranking.fn.init = function() {
		this._registerHelpers();
		this._compileTemplate();
		this.getUsersInService();
	};	

	Ranking.fn.clearTimeReload = function() {
		clearInterval( this.interval );
		this.interval = null;
	};

	Ranking.fn.getUsersInService = function() {
		var promises = this.users.map(function(user) {
			return JEDAI.User( user ).getCodeivateAPI();
		});

		RSVP.all( promises )
		    .then( this._thenPromiseAll.bind(this) )
		    .catch( this._catchPromiseAll.bind(this) )
		;    
	};

	Ranking.fn._thenPromiseAll = function(users) {
		this.users = users.sort(function(a, b) {
			return ( a.getLevel() > b.getLevel() ) ? -1 : 1;
		});
		
		this.render();		
	};

	Ranking.fn.render = function() {
		this.container.html( this.template( this.users ) );
		this.parseElementEachUsers();
		this.callMethodInUsers( 'renderPercentage' );
	};

	Ranking.fn.callMethodInUsers = function(method) {
		this.users.forEach( Ranking.call( method ) );
	};

	Ranking.fn.parseElementEachUsers = function() {
		this.users.forEach(function(user) {
			user.$el = this._getElementUserByName( user.getSanitizeText() );
		}, this);
	};

	Ranking.fn._getElementUserByName = function(name) {
		return this.container.find( '[data-component-profile=' + name + ']' );
	};

	Ranking.fn._catchPromiseAll = function(reason) {

	};

	Ranking.fn._compileTemplate = function() {
		this.template = $( '#template-items-profile' ).compileHandlebars();
	};

	Ranking.fn._registerHelpers = function() {
		Handlebars.registerHelper( 'floor_value', function(value) {
			return Math.floor( value );
		});
	};

	Ranking.call = function(method) {
		return function(user) {
			user[method].call(user);
		};
	};

	//easy compile template
	$.fn.compileHandlebars = function() {
		return Handlebars.compile( this.html() );
	};
});
@@ -37,16 +37,59 @@
 king) %7B%0A
+%09Ranking.TIME_RELOAD = ( 1 * 60 * 1000 );%0A%0A
 %09Ranking
@@ -130,24 +130,24 @@
 r, users) %7B%0A
-
 %09%09this.conta
@@ -363,12 +363,261 @@
 ();%0A
+%09%09this.setTimeReload();%0A%09%7D;%0A%0A%09Ranking.fn.setTimeReload = function() %7B%0A%09%09this.interval = setInterval(%0A%09%09%09(function() %7B%0A%09%09%09%09this.getUsersInService();%0A%09%09%09%09console.log( 'reload page #' + this.interval );%0A%09%09%09%7D).bind(this)%0A%09%09    , Ranking.TIME_RELOAD%0A%09%09);%0A
 %09%7D;
-%09
 %0A%0A%09R

set interval for reload results in ranking