Showing posts with label reports. Show all posts
Showing posts with label reports. Show all posts

Tuesday, July 10, 2012

testlink: Removing columns from Query Metrics report

We wanted to remove 2 columns from the excel version only of the Query Metrics report, the Build and the Time.

I did play with the php code for some while for the file resultsMoreBuilds.php located in lib\results, then I discovered that I can only hide the values.

To hide the whole column, I need to look into the template.

I opened the template file \testlink\gui\templates\results\resultsMoreBuilds.tpl

located the lines for these 2 columns, 6 lines, 2 for the header,

<th>{$tlImages.sort_hint}{$labels.th_build}</th>

<th>{$tlImages.sort_hint}{$labels.th_execution_ts}</th>

and the same header lines for suit summaries

then another 2 lines for the data

<td style="text-align:center;">{$gui->builds_html[$inst.build_id]|escape}</td>

<td style="text-align:center;">{$inst.execution_ts|strip_tags|escape} </td>

In order to hide these columns from the excel only, which has the value of 3, I added if condition before these lines,

{if ($gui->report_type <> 3)}

In order to pass the report type with the gui object, I have modified \testlink\lib\results\resultsMoreBuilds.php, added a line just after this line $gui = initializeGui($db,$args,$date_format_cfg);

I added $gui->report_type = $args->report_type;

For example the first line will be like this

{if ($gui->report_type <> 3)}<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}

Applying the same for the rest of the 6 lines, the 2 columns, Build and Time where not displayed in the extracted excel file

If someone wants to hide these columns from all report types, then simply instead of the if condition, just add an comment, like will look like

<!--<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}-->

Monday, November 21, 2011

Testlink: Timeout Exception in reports after setting up integration with Bug tracking system

We are using testlink and already did setup for integration with bug tracking system that we are using, trac. While doing testing after this step we found out that some reports are not working and it is giving timeout exception

after digging into the code looking for why this is happening, I found out that there is some loop that is calling the bug tracking system for each bug attached to test case.

The function that is called to get the bug is called get_bugs_for_exec, found in exec.inc.php file

This function is not causing any problem when opening the test cases, it is listing the bugs and getting the bug data from bug tracking system without any problems

To workaround the error I am getting in the reports, I have created another function called get_bugs_for_exec_reports with the same implementation but instead of calling the bug interface to get bug details, I just commented this part and only displayed the bug number, this will be enough for the reports, then in reports files, I changed instead of calling get_bugs_for_exec, I am calling get_bugs_for_exec_reports

files where I have done this change

\lib\functions\results.class.php

\lib\results\resultsByStatus.php

\lib\results\resultsBugs.php

Function:

function get_bugs_for_exec_report(&$db,&$bug_interface,$execution_id)
{
    $tables['execution_bugs'] = DB_TABLE_PREFIX . 'execution_bugs';
    $tables['executions'] = DB_TABLE_PREFIX . 'executions';
    $tables['builds'] = DB_TABLE_PREFIX . 'builds';
   
    $bug_list=array();
    $sql = "SELECT execution_id,bug_id,builds.name AS build_name " .
        "FROM {$tables['execution_bugs']}, {$tables['executions']} executions, " .
        " {$tables['builds']} builds ".
        "WHERE execution_id={$execution_id} " .
        "AND   execution_id=executions.id " .
        "AND   executions.build_id=builds.id " .
        "ORDER BY builds.name,bug_id";
    $map = $db->get_recordset($sql);
   
    // BUGID 3440 - added is_object() check
    if( !is_null($map) && is_object($bug_interface))
    {     
        foreach($map as $elem)
        {
            $bug_list[$elem['bug_id']]['link_to_bts'] = $elem['bug_id'];#$bug_interface->buildViewBugLink($elem['bug_id'],GET_BUG_SUMMARY);
            $bug_list[$elem['bug_id']]['build_name'] = $elem['build_name'];
        }
    }   
    return($bug_list);
}