Anonymous Login
2016-07-26 02:21 EDT

View Issue Details Jump to Notes ] Wiki ]
IDProjectCategoryView StatusLast Update
0008656mantisbtapi soappublic2015-10-27 04:25
Reportermwietscher 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
StatusconfirmedResolutionopen 
Product Version1.1.0rc3 
Target VersionFixed in Version 
Summary0008656: please provide function that return issue count of current filter
Descriptionto 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
TagsNo tags attached.
Attached Files
  • patch file icon mantis-8656.patch (5,004 bytes) 2015-10-25 18:20 -
    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 &quot;-1&quot; 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.
    
    
    patch file icon mantis-8656.patch (5,004 bytes) 2015-10-25 18:20 +

-Relationships
+Relationships

-Notes
winston

~0034453

winston (reporter)

Doesn't using mc_filter_get_issues() or mc_filter_get_issue_headers() with per_page = -1 solve this issue?
rombert

~0034506

rombert (developer)

How would that work?
winston

~0034507

winston (reporter)

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.
rombert

~0034509

rombert (developer)

Right, but you'll always retrieve the full bug listing which probably isn't what you want from a performance point of view.
atrol

~0039124

atrol (developer)

Unassigned after having been assigned for a long time without progress.
rewt

~0051723

rewt (reporter)

Attached is a patch for this issue which applies to Mantis 1.2.19 to add mc_filter_get_issue_count.
rombert

~0051724

rombert (developer)

@rewt, thanks for the patch! I have a couple of comments

- it would be great to attach a minimal test - there are quite a few at https://github.com/mantisbt/mantisbt/blob/master/tests/soap/FilterTest.php
- is it possible to just count the issues withoug calling filter_get_bug_rows , which actually loads all the data?
dregad

~0051725

dregad (developer)

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 !

[1] https://github.com/mantisbt/mantisbt
rewt

~0051726

rewt (reporter)

@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.
dregad

~0051733

dregad (developer)

OK fair enough.
+Notes

-Issue History
Date Modified Username Field Change
2007-12-06 17:41 mwietscher New Issue
2007-12-15 20:23 vboctor Status new => acknowledged
2008-05-02 17:17 daryn Status acknowledged => assigned
2008-05-02 17:17 daryn Assigned To => daryn
2012-03-06 06:55 rombert Target Version => 1.3.0-beta.1
2012-12-03 11:44 winston Note Added: 0034453
2012-12-08 07:15 rombert Note Added: 0034506
2012-12-08 07:58 winston Note Added: 0034507
2012-12-09 07:25 rombert Note Added: 0034509
2014-01-21 16:20 atrol Note Added: 0039124
2014-01-21 16:21 atrol Assigned To daryn =>
2014-01-21 16:21 atrol Status assigned => confirmed
2014-01-21 16:21 atrol Target Version 1.3.0-beta.1 =>
2015-10-25 18:20 rewt File Added: mantis-8656.patch
2015-10-25 18:20 rewt Note Added: 0051723
2015-10-26 05:49 rombert Note Added: 0051724
2015-10-26 08:19 dregad Note Added: 0051725
2015-10-26 09:01 rewt Note Added: 0051726
2015-10-27 04:25 dregad Note Added: 0051733
+Issue History