AnsweredAssumed Answered

Get number of Defects logged by a user

Question asked by 5196e9844217c3f28e662fea1de2a375 on Dec 9, 2015
Latest reply on Dec 15, 2015 by 5196e9844217c3f28e662fea1de2a375
I am using node-rally for counting the defects logged by a user. It takes quite a lot of time, because the query is actually getting an array of defects, but I am only interested in the TotalCount. Is there a faster way of getting ONLY the count? Here's my code:
 
getQuery = function(email, year) {
    return {
        type: 'defect',
        start: 1, //the 1-based start index, defaults to 1
        pageSize: 1, //the page size (1-200, defaults to 200)
        limit: Infinity, //the maximum number of results to return- enables auto paging
        // fetch: ['FormattedID', 'Name', 'State', 'CreationDate'], //the fields to retrieve
        fetch: [],
        query: queryUtils.where('SubmittedBy.UserName', '=', email).and('CreationDate', '>', year + '-01-01T00:00:01.000Z').and('CreationDate', '<', year + '-12-31T23:59:59.000Z')
    }
};

_.each(years, function(year) {
    console.log("---------YEAR: " + year);
    var stuff = Async.runSync(function(done) {
        restApi.query(getQuery("myemail@customer.com", year), function(error, result) {
            if (error) {
                console.log("Error: " + error)
                done(null, error);
            };
            console.log("Total count: " + result.TotalResultCount);
            done(null, result);
        });
    });

    Defects.upsert({
        email: "myemail@customer.com"
    }, {
        $push: {
            defects: {
                year: year,
                count: stuff.result.TotalResultCount
            }
        }
    })
});

 

Outcomes