utils/check-status.js
function main() {
    agents.forEach(function (agent) {
        var r = agentdb.lookupPattern(agent.agent);
        if (r !== null) {
            if (agent.groupId == 1) {   // Unknown group -> update agent
                updateAgent(agent.id, r.group, r.source, 2);
            } else if (agent.status != 1) {
                if (r.group == agent.group) {
                    if ((agent.source == 'Unknown') &&
                        (r.source != 'Unknown')) {  // Unknown source -> update agent
                        updateAgent(agent.id, r.group, r.source, 2);
                    } else if ((agent.source == r.source) && (agent.status != 2)) { // 2 is good
                        updateStatus(agent.id, 2);
                    } else if ((agent.source != r.source) && (agent.status != 3)) { // must include exact.
                        updateStatus(agent.id, 1);
                    }
                } else if (agent.status != 3) { // need to include exact.
                    updateStatus(agent.id, 1);
                }
            } else if ((r.group == agent.group) && (r.source == agent.source)) {    // can use pattern
                updateStatus(agent.id, 2);
            }
        } else {
            r = agentdb.lookupHash(agent.agent);
            if (r !== null) {
                if ((r.group != agent.group) || (r.source != agent.source)) {
                    if (debug) { console.error("ERROR: lookup did not match: " + agent.agent); }
                    if (debug) { console.error("  lookup.group=" + r.group+", expected="+agent.group+", lookup.source=" + r.source + ", expected="+agent.source); }
                } else if ((agent.status != 1) && (agent.status != 3)) {
                    updateStatus(agent.id, 1);
                }
            } else {
                if ((agent.status < 3) && ((agent.group != "Unknown") || (agent.source != "Unknown"))) {
                    if (debug) { console.error("ERROR: missing:" + agent.agent); }
                    notfound.push(agent);
                }
            }
        }
    });
    
    if (notfound.length > 0) {
        console.error("Warning: user-agents were not found: " + notfound.length);
        if (createMissing) {
            notfound.forEach(function (agent) {
                addInsert(agent);
            });
        }
    }
}
function main() {
    agents.forEach(function (agent) {
        var r = agentdb.lookupPattern(agent.agent);
        if (r !== null) {
            if (agent.groupId == 1) {   // Unknown group -> update agent
                updateAgent(agent.id, r.group, r.source, 2);
            } else if (agent.status != 1) {
                if (r.group == agent.group) {
                    if ((agent.source == 'Unknown') &&
                        (r.source != 'Unknown')) {  // Unknown source -> update agent
                        updateAgent(agent.id, r.group, r.source, 2);
                    } else if ((agent.source == r.source) && (agent.status != 2)) { // 2 is good
                        updateStatus(agent.id, 2);
                    } else if ((agent.source != r.source) && (agent.status != 3)) { // must include exact.
                        updateStatus(agent.id, 1);
                    }
                } else if (agent.status != 3) { // need to include exact.
                    updateStatus(agent.id, 1);
                }
            } else if ((r.group == agent.group) && (r.source == agent.source)) {    // can use pattern
                updateStatus(agent.id, 2);
            }
        } else {
            r = agentdb.lookupHash(agent.agent);
            if (r !== null) {
                if ((r.group != agent.group) || (r.source != agent.source)) {
                    if (debug) { console.error("ERROR: lookup did not match: " + agent.agent); }
                    if (debug) { console.error("  lookup.group=" + r.group+", expected="+agent.group+", lookup.source=" + r.source + ", expected="+agent.source); }
                } else if ((agent.status != 1) && (agent.status != 3)) {
                    updateStatus(agent.id, 1);
                }
            } else {
                if ((agent.status < 3) && ((agent.group != "Unknown") || (agent.source != "Unknown"))) {
                    if (debug) { console.error("ERROR: missing:" + agent.agent); }
                    notfound.push(agent);
                }
            }
        }
    });
    
    if (notfound.length > 0) {
        console.error("Warning: user-agents were not found: " + notfound.length);
        if (createMissing) {
            notfound.forEach(function (agent) {
                addInsert(agent);
            });
        }
    }
}
function main ( ) { agents . forEach ( function ( agent ) { var r = agentdb . lookupPattern ( agent . agent ) ; if ( r !== null ) { if ( agent . groupId == 1 ) { // Unknown group -> update agent updateAgent ( agent . id , r . group , r . source , 2 ) ; } else if ( agent . status != 1 ) { if ( r . group == agent . group ) { if ( ( agent . source == 'Unknown' ) && ( r . source != 'Unknown' ) ) { // Unknown source -> update agent updateAgent ( agent . id , r . group , r . source , 2 ) ; } else if ( ( agent . source == r . source ) && ( agent . status != 2 ) ) { // 2 is good updateStatus ( agent . id , 2 ) ; } else if ( ( agent . source != r . source ) && ( agent . status != 3 ) ) { // must include exact. updateStatus ( agent . id , 1 ) ; } } else if ( agent . status != 3 ) { // need to include exact. updateStatus ( agent . id , 1 ) ; } } else if ( ( r . group == agent . group ) && ( r . source == agent . source ) ) { // can use pattern updateStatus ( agent . id , 2 ) ; } } else { r = agentdb . lookupHash ( agent . agent ) ; if ( r !== null ) { if ( ( r . group != agent . group ) || ( r . source != agent . source ) ) { if ( debug ) { console . error ( "ERROR: lookup did not match: " + agent . agent ) ; } if ( debug ) { console . error ( "  lookup.group=" + r . group + ", expected=" + agent . group + ", lookup.source=" + r . source + ", expected=" + agent . source ) ; } } else if ( ( agent . status != 1 ) && ( agent . status != 3 ) ) { updateStatus ( agent . id , 1 ) ; } } else { if ( ( agent . status < 3 ) && ( ( agent . group != "Unknown" ) || ( agent . source != "Unknown" ) ) ) { if ( debug ) { console . error ( "ERROR: missing:" + agent . agent ) ; } notfound . push ( agent ) ; } } } } ) ; if ( notfound . length > 0 ) { console . error ( "Warning: user-agents were not found: " + notfound . length ) ; if ( createMissing ) { notfound . forEach ( function ( agent ) { addInsert ( agent ) ; } ) ; } } }
check-status main function.
check - status main function .