Js to achieve the array of id de-duplicated the same id under the value of the addition, ask for advice!

clipboard.png

clipboard.png

Mar.20,2021


var param = [{"HOST_IP":"192.168.167.11","TASK_NAME":"test","MSG_COUNT": 3},

            {"HOST_IP":"192.168.167.12","TASK_NAME":"test","MSG_COUNT": 4},
            {"HOST_IP":"192.168.167.11","TASK_NAME":"test","MSG_COUNT": 5}];
var fileArray =[],flag = true;
for (var i = 0; i< param.length; iPP){
    if(i == 0){
        fileArray.push({"HOST_IP":param[i].HOST_IP,"TASK_NAME":param[i].TASK_NAME,"MSG_COUNT": param[i].MSG_COUNT});
        continue;
    }
    for (var j = 0 ;j <fileArray.length; jPP){
        if(fileArray[j].HOST_IP == param[i].HOST_IP){
            var ip = param[i].HOST_IP;

            var ipResult = fileArray.findIndex(function (value) {
                return value.HOST_IP === param[i].HOST_IP;
            });
            fileArray[ipResult].MSG_COUNT = fileArray[ipResult].MSG_COUNT + param[i].MSG_COUNT;

            flag = false;
            continue;
        }
    }
    if (flag){
        fileArray.push({"HOST_IP":param[i].HOST_IP,"TASK_NAME":param[i].TASK_NAME,"MSG_COUNT": param[i].MSG_COUNT});
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb0302-22bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb0302-22bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?