View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008656 | mantisbt | api soap | public | 2007-12-06 17:41 | 2023-02-17 19:13 |
Reporter | mwietscher | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | have not tried |
Status | confirmed | Resolution | open | ||
Product Version | 1.1.0rc3 | ||||
Summary | 0008656: please provide function that return issue count of current filter | ||||
Description | to be able to design a usable browsing functionality (first, previous, 1, 2, 3, ... 99, next, last) it would be necessary to know the number of issues that fit to current filter please please provide us with function like int mc_filter_get_issue_count(username, password, project_id, filter_id) i know too less about php to do it on my own | ||||
Tags | No tags attached. | ||||
Attached Files | mantis-8656.patch (5,004 bytes)
diff -urN mantis.orig/api/soap/mantisconnect.wsdl mantis/api/soap/mantisconnect.wsdl --- mantis.orig/api/soap/mantisconnect.wsdl 2015-01-25 18:00:30.000000000 -0500 +++ mantis/api/soap/mantisconnect.wsdl 2015-10-25 16:34:05.000000000 -0400 @@ -738,6 +738,13 @@ <part name="per_page" type="xsd:integer" /></message> <message name="mc_filter_get_issuesResponse"> <part name="return" type="tns:IssueDataArray" /></message> +<message name="mc_filter_get_issue_countRequest"> + <part name="username" type="xsd:string" /> + <part name="password" type="xsd:string" /> + <part name="project_id" type="xsd:integer" /> + <part name="filter_id" type="xsd:integer" /></message> +<message name="mc_filter_get_issue_countResponse"> + <part name="return" type="xsd:integer" /></message> <message name="mc_filter_get_issue_headersRequest"> <part name="username" type="xsd:string" /> <part name="password" type="xsd:string" /> @@ -1089,6 +1096,11 @@ <input message="tns:mc_filter_get_issuesRequest"/> <output message="tns:mc_filter_get_issuesResponse"/> </operation> + <operation name="mc_filter_get_issue_count"> + <documentation>Get the count of issues that match the specified filter.</documentation> + <input message="tns:mc_filter_get_issue_countRequest"/> + <output message="tns:mc_filter_get_issue_countResponse"/> + </operation> <operation name="mc_filter_get_issue_headers"> <documentation>Get the issue headers that match the specified filter and paging details. Pass "-1" for the per_page parameter to get all issues.</documentation> <input message="tns:mc_filter_get_issue_headersRequest"/> @@ -1427,6 +1439,11 @@ <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> + <operation name="mc_filter_get_issue_count"> + <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_filter_get_issue_count" style="rpc"/> + <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> + <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> + </operation> <operation name="mc_filter_get_issue_headers"> <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_filter_get_issue_headers" style="rpc"/> <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> diff -urN mantis.orig/api/soap/mc_filter_api.php mantis/api/soap/mc_filter_api.php --- mantis.orig/api/soap/mc_filter_api.php 2015-01-25 18:00:30.000000000 -0500 +++ mantis/api/soap/mc_filter_api.php 2015-10-25 16:38:23.000000000 -0400 @@ -84,6 +84,46 @@ } /** + * Get count of issues matching the specified filter. + * + * @param string $p_username The name of the user trying to access the filters. + * @param string $p_password The password of the user. + * @param integer $p_project_id The id of the project to retrieve filters for. + * @param integer $p_filter_id The id of the filter to apply. + * @return Array that represents an IssueDataArray structure + */ +function mc_filter_get_issue_count( $p_username, $p_password, $p_project_id, $p_filter_id) { + $t_user_id = mci_check_login( $p_username, $p_password ); + if( $t_user_id === false ) { + return mci_soap_fault_login_failed(); + } + $t_lang = mci_get_user_lang( $t_user_id ); + + if( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) { + return mci_soap_fault_access_denied( $t_user_id ); + } + + $p_page_number = 0; + $p_per_page = -1; + + $t_orig_page_number = $p_page_number < 1 ? 1 : $p_page_number; + $t_page_count = 0; + $t_bug_count = 0; + $t_filter = filter_db_get_filter( $p_filter_id ); + $t_filter_detail = explode( '#', $t_filter, 2 ); + if( !isset( $t_filter_detail[1] ) ) { + return SoapObjectsFactory::newSoapFault( 'Server', 'Invalid Filter' ); + } + $t_filter = unserialize( $t_filter_detail[1] ); + $t_filter = filter_ensure_valid_filter( $t_filter ); + + $t_result = array(); + $t_rows = filter_get_bug_rows( $p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id ); + + return $t_bug_count; +} + +/** * Get the issue headers that match the specified filter and paging details. * * @param string $p_username The name of the user trying to access the filters. | ||||
Doesn't using mc_filter_get_issues() or mc_filter_get_issue_headers() with per_page = -1 solve this issue? |
|
How would that work? |
|
Documentation of those functions says: 'Pass "-1" for the per_page parameter to get all issues.' - so there is a way to know the number of bugs that fit the filter. |
|
Right, but you'll always retrieve the full bug listing which probably isn't what you want from a performance point of view. |
|
Unassigned after having been assigned for a long time without progress. |
|
Attached is a patch for this issue which applies to Mantis 1.2.19 to add mc_filter_get_issue_count. |
|
@rewt, thanks for the patch! I have a couple of comments
|
|
Also, if it's not too much trouble for you, we would prefer to receive patch submissions as a pull request on our Github repo [1], as it facilitates the code review and merging process. Thanks ! |
|
@rombert - unfortunately it's filter_get_bug_rows that does all the heavy lifting. You could shim that and inject a COUNT(*) instead of the DISTINCT clause if you want to avoid the overhead of loading all the data but the performance of this was good enough for my limited needs. Adding tests and submitting pull requests via Github both have too much friction for me right now. I don't want/need to set up a dev environment for this - it was a quick hack to scratch a particular itch that I had and I thought others might find it useful. YMMV. |
|
OK fair enough. |
|