0

I want to use the trac data (ticket information,status,etc) in a webpage, since the data retrieval is very very slow (The reason I explain this is because am afraid my problem may be XY Problem) and hence I exported all the data to a DB for faster access.

Now the problem is if someone updates a ticket then I have old data in DB. Even if I update my DB after regular intervals then also between two updates someone could have updated the ticket and someone could have requested the info on the website.

So i thought what if the trac updates my DB, after each new ticket creation or a ticket modification.

So i need to put a post script somewhere that will execute each time the trac is updated and will update my DB.

If its not possible then I am willing to migrate to Redmine if its possible to do the same in it.

Update 1
Trac Version  : 0.11.5
Plugins          : No idea, Its company trac, I cannot find anything in the GUI
Java api        : XML-RPC
Time taking   : 20-30 seconds

Update 2
Here's my code

     XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl ();
     config.setBasicUserName ("harry");
     config.setBasicPassword ("my_passwd");
     config.setServerURL(new URL("https://host.domain.com/project/trac/login/xmlrpc")); 
     XmlRpcClient client = new XmlRpcClient();    
     client.setConfig (config); 
     TrackerDynamicProxy xmlRpcProxy = new TrackerDynamicProxy(client);

     Ticket ticket = (Ticket)xmlRpcProxy.newInstance(Ticket.class);

     Vector vector = ticket.query(); // gives all ticket number
         for(Object obj : vector)
            ticket.get((Integer)obj).get(3);     // summary column   


This way each ticket almost takes half second, and there are many tickets so it takes around 20-30 seconds overall.

Community
  • 1
  • 1
Harry
  • 1,572
  • 2
  • 17
  • 31
  • Would be good to know about the Trac install you have issues (large response time) with. Please include at least Trac version, installed Trac plugins and their versions, if any, and the Trac db backend type. – hasienda Sep 01 '14 at 20:51
  • While you could update your database in response to a ticket change by implementing [ITicketChangeListener](http://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.ticket.api.ITicketChangeListener), I suggest heading down the path that @hasienda is pushing you towards, of trying to figure out why the data retrieval is slow. Are Trac and your other webpage both served from the same webserver? Or are they are least running on the same physical server, or two physical or virtual servers with a fast connection between them? – RjOllos Sep 02 '14 at 05:21
  • Also your Trac version is very old, and I suggest updating to at least 0.12.5, but preferably 1.0.1 (0.12.6 and 1.0.2 will be released soon). – RjOllos Sep 02 '14 at 05:24
  • @RjOllos I cannot do anything about the version, I am just an employee in company, but thanks a TON for the plugin, was really looking for this !!! If you could post an similar answer may be with a example I can accept the solution and close this question. – Harry Sep 02 '14 at 22:47
  • @RjOllos I have installed the plugin but where should i write the code, the example shown is in python, so should I put that code ?? – Harry Sep 03 '14 at 02:04
  • I guess you mean that you've installed the [Example Plugin](http://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.ticket.api.ITicketChangeListener#Examples). Yes, you'll need to write some code in Python. Inside the methods such as `ticket_created` you can use the `ticket` attributes to execute database queries against your external database that needs to be updated. The page links to many examples from the trac codebase and plugins on trac-hacks.org that you can use for guidance in how to implement `ITicketChangeListener`. – RjOllos Sep 03 '14 at 02:23
  • @RjOllos yeah but WHERE TO PUT THAT CODE ? – Harry Sep 03 '14 at 02:34
  • It is unclear what you are asking, but if you are asking where to install the plugin, that information can be found on the [TracPlugins](http://trac.edgewall.org/wiki/TracPlugins) page. If you are asking where to put the code inside the class implementing `ITicketChangeListener`, I already mentioned that you need to implement the methods `ticket_created`, `ticket_changed`, `ticket_deleted`. – RjOllos Sep 03 '14 at 03:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60489/discussion-between-harendra-singh-and-rjollos). – Harry Sep 03 '14 at 03:38

2 Answers2

0

I know nothing about trac.

About Redmine: yes you can write a simple plugin which will use one of hook or just add a callback to Issue model.

way 1 (hook): Here you can find a hook list. You can add sending a callback to controller_issues_edit_after_save. You can use these variables: :params, :issue, :time_entry, :journal (but I think you need just issue)

way 2 (callback in the model): You can patch model Issue to add callback. You can add several callbacks, for example after_save, after_destroy. The logic for all callback - send data of issue (or just inform another server that issue with id is changed).

Hope it helps you.

gotva
  • 5,919
  • 2
  • 25
  • 35
0

As suggested by other members in the comment that its better to find the cause of large delay, so I looked into it and found that when you need to send queries to TRAC many times then you should better use MULTICALL instead of firing single query multiple times.


MultiCall packs all the queries into one object and send it, so the overhead is very small as compared to sending queries many times

After using multicall my times was decreased from 20-30 seconds to 2-3 seconds, almost 10x gain !

Unfortunately I could not find any java example or documentation on how to use multicall so I ended up using python instead.

Short Answer Use MultiCall()

Harry
  • 1,572
  • 2
  • 17
  • 31