"use strict";

//Load dependencies
var async = require("async");
var applicationStorage = process.require("core/applicationStorage.js");
var rankModel = process.require("ranks/rankModel.js");
var updateModel = process.require("updates/updateModel.js");

/**
 * WeeklyCronProcess constructor
 * @constructor
 */
function WeeklyCronProcess() {
}

WeeklyCronProcess.prototype.runCron = function () {
    var logger = applicationStorage.logger;
    var config = applicationStorage.config;

    async.forEach(config.progress.raids,function(raid,callback){
        async.waterfall([
            function(callback){
                //Load all guild in progress
                rankModel.getRanking("tier_18_us",0,999999,function(error,ranking){
                    callback(error,ranking);
                });
            },
            function(ranking,callback) {
                async.forEachSeries(ranking,function(guildStr,callback){
                    var guildArray = guildStr.split('-');

                    //Fix realm with - ... silly choice ...
                    if(guildArray.length ==4){
                        guildArray[1] = guildArray[1]+"-"+guildArray[2];
                        guildArray[2] = guildArray[3];
                    }
                    updateModel.insert("wp_gu", guildArray[0], guildArray[1], guildArray[2], 3, function (error) {
                        logger.info("Insert guild progress %s-%s-%s to update with priority 3", guildArray[0], guildArray[1], guildArray[2]);
                        if(error){
                            logger.error(error.message);
                        }
                        callback(error);
                    });
                },function(error){
                    callback(error);
                });
            }
        ],function(error){
            if (error){
                logger.error(error.message);
            }
            callback();
        });
    },function(error){
        if (error){
            logger.error(error.message);
        }
        process.exit();
    });


};

/**
 * Start WeeklyCronProcess
 * @param callback
 */
WeeklyCronProcess.prototype.start = function (callback) {
    applicationStorage.logger.info("Starting WeeklyCronProcess");
    this.runCron();
    callback();
};

module.exports = WeeklyCronProcess;
@@ -688,20 +688,31 @@
 ing(
-%22tier_18_us%22
+raid.tier+%22#%22+raid.name
 ,0,9
@@ -993,271 +993,14 @@
 it('
--
+#
 ');%0A%0A
-                    //Fix realm with - ... silly choice ...%0A                    if(guildArray.length ==4)%7B%0A                        guildArray%5B1%5D = guildArray%5B1%5D+%22-%22+guildArray%5B2%5D;%0A                        guildArray%5B2%5D = guildArray%5B3%5D;%0A                    %7D%0A
     

Fix cron