Create Custom Reports in OTRS and Retrieve "Age" from DB
Moderator: crythias
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Create Custom Reports in OTRS and Retrieve "Age" from DB
I have written an extremely complex SQL query and I want to create a customized report in OTRS with it. How can I go about doing this? I have looked through all of the *.pm files and I was unable to find any where I could simply enter a query and run that report from the system itself. Right now I am running the report using PuTTy and PGADMIN3. The reason I am having to do this is because OTRS has not exposed the ticket_history table in the statistics module and I am unable to acquire some very basic historical data.
The second part of the query is with reference to the "Age" value that is associated with each and every single ticket. I can see the "Age" value in the GUI but I can't find the value itself in any of the tables. What's worst I can't figure out which two values I can use to calculate it myself. Can anyone help me here?
The second part of the query is with reference to the "Age" value that is associated with each and every single ticket. I can see the "Age" value in the GUI but I can't find the value itself in any of the tables. What's worst I can't figure out which two values I can use to calculate it myself. Can anyone help me here?
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Age = now minus ticket create date.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Thank you for the prompt response crythias; however the problem with that is non-working hours would be considered as well. I want to calculate "Age" as it is being calculated in the system (i.e. now minus create date minus non-working hours). Any idea how I can do that?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
If you take a look at the API of the TimeObject, there's a function that let's you calculate (working-) time diff with three params:
- Date 1
- Date 2
- Calendar to use
- Date 1
- Date 2
- Calendar to use
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Where can I find the API of the TimeObject RStraub? Let's say I find the API of the TimeObject, could I make this calculation via the DB directly? Or would I need to execute Perl script for it?
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
https://otrs.github.io/doc/api/otrs/sta ... me.pm.html
It's probably best to create a perl module that asks OTRS what it knows and use it for a stats report.
The math will probably boggle your SQL skills.zyousafi wrote: could I make this calculation via the DB directly? Or would I need to execute Perl script for it?
It's probably best to create a perl module that asks OTRS what it knows and use it for a stats report.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
yes crythias my SQL skills will be put to the test; however I have a team of professionals who can help me with that. they just don't know have enough knowledge about OTRS and they don't know where that information would be stored. is there a way to be able to calculate this via SQL? what i, or my colleagues, don't have is PERL skills and that's why I would like to avoid that if at all possible.
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Like I said, Age is now minus CreateTime:
https://github.com/OTRS/otrs/blob/rel-4 ... t.pm#L1200
Perhaps you want WorkingTime:
https://github.com/OTRS/otrs/blob/rel-4 ... me.pm#L414
https://github.com/OTRS/otrs/blob/rel-4 ... t.pm#L1200
Code: Select all
$Ticket{Age} = $TimeObject->SystemTime() - $Ticket{CreateTimeUnix};
https://github.com/OTRS/otrs/blob/rel-4 ... me.pm#L414
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
I want "Age" as it is calculated in the system. Yes it's "Now () - CreateTime" however it takes the settings in the calendar into consideration. Is there anyway to do that via the DB.
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Good luck. I don't know how you come to that conclusion, especially since I showed you where age is calculated. And no, there is no magic that moves create time or now because of calendar.zyousafi wrote: want "Age" as it is calculated in the system. Yes it's "Now () - CreateTime" however it takes the settings in the calendar into consideration.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 64
- Joined: 09 Feb 2015, 12:03
- Znuny Version: 4.0.5
- Real Name: Zohair Yousafi
Re: Create Custom Reports in OTRS and Retrieve "Age" from DB
Okay well that's interesting. When I evaluated "Age" it seems it only counts working hours. The working hours that the user defines in the calendar. I will look at the code you shared again and track it in the system.