0

Can I get the number of tickets using the Trac XML-RPC Plugin, without requiring all tickets from the server?

The trac API describes parameter "format=count", but it does not work for me ...
I'm trying to run the following code:

import xmlrpclib
server = xmlrpclib.ServerProxy("https://user:password@trac-server/login/xmlrpc")
multicall = xmlrpclib.MultiCall(server)
for t in server.ticket.query('status=new&format=count&max=3'):
    print t

... but get only ticket numbers, not the number of it.

I can count so:

import xmlrpclib
server = xmlrpclib.ServerProxy("https://user:password@trac-server/login/xmlrpc")
multicall = xmlrpclib.MultiCall(server)
print( server.ticket.query('max=0') )

... but I think it's not a very optimal way, because this method loads all data from the server.

Is there a way to get the number of tickets without requiring a complete list and counting it?

Sank
  • 121
  • 1
  • 4

1 Answers1

0

You simply have a semantical error. Use commas instead of ampersand to separate the format from the query condition. The max=3 parameter is not useful here. Then your query will look like this:

for t in server.ticket.query('status=new,format=count'):
    print t

and the result is just a number telling the count under the given condition status=new. Change the condition by adding more terms via ampersand, e.g. status=new&owner=joe.

falkb
  • 1,294
  • 11
  • 35
  • No, it does not work. It seems to me that the trac is trying to apply a filter status='new,format=count' or something like that. – Sank Nov 22 '13 at 11:22