Re: [rt-users] Perl API: list of available queues, owners, status
On 13 Jul 2012, at 01:01, Richard McMahon wrote: OK, that gets me the queue list. Is there an API way to get the full list of valid status values That's part of the configuration; it's not an API as such. That information is all configurable by you in the %Lifecycle configuration (look in RT_Config.pm). See the documentation for the RT::Lifecycle module: my $lifecycle = RT::Lifecycle-Load('default'); my @statuses = $lifecycle-Valid; probably gets you what you want. Most of the perl classes that the BestPractical guys expect us to use in scripts have reasonable pod documentation, although often you have to remember to also consult the superclass documentation as well, since sometimes the documentation is at that level, in things like RT::Record and RT::SearchBuilder. and also the list of names of ticket owners. Well, you can always construct that from any list of tickets that you've previously obtained. The method is similar to the one mentioned before for iterating over queues; instead, you iterate over the tickets and fetch the name of the owner from each one. Note that this is likely to be quite slow if there are a lot of tickets. You could, of course query the database directly, with something like: select distinct(u.Name) from Users u, Tickets t where t.Owner = u.id; but querying the database directly is not generally considered a smart thing to do, although I doubt this part of the schema is going to change any time soon. I have looked that the code that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. I find that most of the RT code base itself is usually fairly clear (with the exceptions of some of the hairier web interface corners), and when I want to find out how to do something in the RT API I just search the main RT code for places where the same thing is being done, and copy it! Regards, Tim -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
Re: [rt-users] Perl API: list of available queues, owners, status
On Fri, Jul 13, 2012 at 10:01:33AM +0100, Tim Cutts wrote: On 13 Jul 2012, at 01:01, Richard McMahon wrote: OK, that gets me the queue list. Is there an API way to get the full list of valid status values That's part of the configuration; it's not an API as such. That information is all configurable by you in the %Lifecycle configuration (look in RT_Config.pm). See the documentation for the RT::Lifecycle module: my $lifecycle = RT::Lifecycle-Load('default'); my @statuses = $lifecycle-Valid; probably gets you what you want. Most of the perl classes that the BestPractical guys expect us to use in scripts have reasonable pod documentation, although often you have to remember to also consult the superclass documentation as well, since sometimes the documentation is at that level, in things like RT::Record and RT::SearchBuilder. You really don't want to go about it that way. You want to ask the Queue for the valid statuses, which is why I pointed to the perldoc for Queue.pm. A Queue object can get you both global and queue specific sets of statuses, and it can also tell you if a Status is valid for a given Queue. and also the list of names of ticket owners. Well, you can always construct that from any list of tickets that you've previously obtained. The method is similar to the one mentioned before for iterating over queues; instead, you iterate over the tickets and fetch the name of the owner from each one. Note that this is likely to be quite slow if there are a lot of tickets. You could, of course query the database directly, with something like: select distinct(u.Name) from Users u, Tickets t where t.Owner = u.id; but querying the database directly is not generally considered a smart thing to do, although I doubt this part of the schema is going to change any time soon. This is a list of people who are currently Owners, which is not actually the same as people who can be owners. -kevin I have looked that the code that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. I find that most of the RT code base itself is usually fairly clear (with the exceptions of some of the hairier web interface corners), and when I want to find out how to do something in the RT API I just search the main RT code for places where the same thing is being done, and copy it! pgpdXuQMJ7vkU.pgp Description: PGP signature
Re: [rt-users] Perl API: list of available queues, owners, status
Ok, I am nearly there. Yes, I have looked the perldoc but got a little lost. It is very comprehensive but Perl is my third language :). I am nearly there. I need the list of possible ticket owners. This is the list of people in the admin group, maybe. My previous report scripts used raw sql but I want to rewrite the reports using as much of the RT API code bases as possible. Below I summarise the input on getting the valid status values; note we have some extra ones and the queuses my $lifecycle = RT::Lifecycle-Load('default'); my @statuses = $lifecycle-Valid; for my $status (@statuses) { print $status, \n; } my $queues = RT::Queues-new( RT-SystemUser ); $queues-UnLimit; while ( my $queue = $queues-Next ) { print $queue-Name, \n; } So, is there something simialar that list the members who can own a ticket? thanks On Fri, 13 Jul 2012, Tim Cutts wrote: Date: Fri, 13 Jul 2012 10:01:33 +0100 From: Tim Cutts t...@sanger.ac.uk To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On 13 Jul 2012, at 01:01, Richard McMahon wrote: OK, that gets me the queue list. Is there an API way to get the full list of valid status values That's part of the configuration; it's not an API as such. That information is all configurable by you in the %Lifecycle configuration (look in RT_Config.pm). See the documentation for the RT::Lifecycle module: my $lifecycle = RT::Lifecycle-Load('default'); my @statuses = $lifecycle-Valid; probably gets you what you want. Most of the perl classes that the BestPractical guys expect us to use in scripts have reasonable pod documentation, although often you have to remember to also consult the superclass documentation as well, since sometimes the documentation is at that level, in things like RT::Record and RT::SearchBuilder. and also the list of names of ticket owners. Well, you can always construct that from any list of tickets that you've previously obtained. The method is similar to the one mentioned before for iterating over queues; instead, you iterate over the tickets and fetch the name of the owner from each one. Note that this is likely to be quite slow if there are a lot of tickets. You could, of course query the database directly, with something like: select distinct(u.Name) from Users u, Tickets t where t.Owner = u.id; but querying the database directly is not generally considered a smart thing to do, although I doubt this part of the schema is going to change any time soon. I have looked that the code that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. I find that most of the RT code base itself is usually fairly clear (with the exceptions of some of the hairier web interface corners), and when I want to find out how to do something in the RT API I just search the main RT code for places where the same thing is being done, and copy it! Regards, Tim --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon ---
Re: [rt-users] Perl API: list of available queues, owners, status
OK, I have looked at: the SelectOwnerDrop template and came up with this which does what I want to get the list of valid owners: my $Users = RT::Users-new( RT-SystemUser ); $Users-WhoHaveRight( Right = 'OwnTicket', ); while ( my $Users = $Users-Next ) { print $Users-Name, \n; } Thanks for the pointer On Thu, 12 Jul 2012, Kevin Falcone wrote: Date: Thu, 12 Jul 2012 21:36:55 -0400 From: Kevin Falcone falc...@bestpractical.com Reply-To: rt-users@lists.bestpractical.com To: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Fri, Jul 13, 2012 at 01:01:05AM +0100, Richard McMahon wrote: Is there an API way to get the full list of valid status values and also Have you tried running perldoc /opt/rt4/lib/RT/Queue.pm and searching for Status? the list of names of ticket owners. I have looked that the code Look at what the SelectOwner template does to get an owner list. -kevin that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. thanks I know how to this sort of thing with RAW SQL but prefer to try to use the API. I have looked at QueueSummaryByStatus in RT4 but thanks On Thu, 12 Jul 2012, Kevin Falcone wrote: Date: Thu, 12 Jul 2012 15:00:00 -0400 From: Kevin Falcone falc...@bestpractical.com Reply-To: rt-users@lists.bestpractical.com To: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 07:43:16PM +0100, Richard McMahon wrote: I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. In that case, it's probably easier to -Load the queue by name and see if it exists, rather than list 20 queues and name compare each. -kevin On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon --- --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon ---
Re: [rt-users] Perl API: list of available queues, owners, status
On 13 Jul 2012, at 15:51, Kevin Falcone wrote: You really don't want to go about it that way. You want to ask the Queue for the valid statuses, which is why I pointed to the perldoc for Queue.pm. A Queue object can get you both global and queue specific sets of statuses, and it can also tell you if a Status is valid for a given Queue. I stand corrected. and also the list of names of ticket owners. Well, you can always construct that from any list of tickets that you've previously obtained. The method is similar to the one mentioned before for iterating over queues; instead, you iterate over the tickets and fetch the name of the owner from each one. Note that this is likely to be quite slow if there are a lot of tickets. You could, of course query the database directly, with something like: select distinct(u.Name) from Users u, Tickets t where t.Owner = u.id; but querying the database directly is not generally considered a smart thing to do, although I doubt this part of the schema is going to change any time soon. This is a list of people who are currently Owners, which is not actually the same as people who can be owners. I must have misinterpreted the question. If that's what he's after, then I'd have looked at the Mason components which provide a list of possible owners for a ticket, and copy the way that does it. Regards, Tim -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
Re: [rt-users] Perl API: list of available queues, owners, status
On Fri, Jul 13, 2012 at 09:59:49PM +0100, Tim Cutts wrote: but querying the database directly is not generally considered a smart thing to do, although I doubt this part of the schema is going to change any time soon. This is a list of people who are currently Owners, which is not actually the same as people who can be owners. I must have misinterpreted the question. If that's what he's after, then I'd have looked at the Mason components which provide a list of possible owners for a ticket, and copy the way that does it. Yep, that's where I pointed him and where he eventually found it. I'd still implement this by accepting a user name, loading and error checking the name and then checking HasRight on the user and the Queue, but there are many ways to do this. -kevin pgpuOpfkZGJUm.pgp Description: PGP signature
[rt-users] Perl API: list of available queues, owners, status
Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. Thanks Richard --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon ---
Re: [rt-users] Perl API: list of available queues, owners, status
On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. Thanks Richard -- Best regards, Ruslan.
Re: [rt-users] Perl API: list of available queues, owners, status
Hi, I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. r. On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. Thanks Richard --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon ---
Re: [rt-users] Perl API: list of available queues, owners, status
On Thu, Jul 12, 2012 at 9:43 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hi, I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. my $queues = RT::Queues-new( RT-SystemUser ); $queues-UnLimit; while ( my $queue = $queues-Next ) { print $queue-Name, \n; } r. On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. Thanks Richard --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon --- -- Best regards, Ruslan.
Re: [rt-users] Perl API: list of available queues, owners, status
On Thu, Jul 12, 2012 at 07:43:16PM +0100, Richard McMahon wrote: I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. In that case, it's probably easier to -Load the queue by name and see if it exists, rather than list 20 queues and name compare each. -kevin On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. pgpSi6j4Ufof1.pgp Description: PGP signature
Re: [rt-users] Perl API: list of available queues, owners, status
OK, that gets me the queue list. Is there an API way to get the full list of valid status values and also the list of names of ticket owners. I have looked that the code that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. thanks I know how to this sort of thing with RAW SQL but prefer to try to use the API. I have looked at QueueSummaryByStatus in RT4 but thanks On Thu, 12 Jul 2012, Kevin Falcone wrote: Date: Thu, 12 Jul 2012 15:00:00 -0400 From: Kevin Falcone falc...@bestpractical.com Reply-To: rt-users@lists.bestpractical.com To: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 07:43:16PM +0100, Richard McMahon wrote: I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. In that case, it's probably easier to -Load the queue by name and see if it exists, rather than list 20 queues and name compare each. -kevin On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon ---
Re: [rt-users] Perl API: list of available queues, owners, status
On Fri, Jul 13, 2012 at 01:01:05AM +0100, Richard McMahon wrote: Is there an API way to get the full list of valid status values and also Have you tried running perldoc /opt/rt4/lib/RT/Queue.pm and searching for Status? the list of names of ticket owners. I have looked that the code Look at what the SelectOwner template does to get an owner list. -kevin that Ruslan mentions but I am able see how to get at the owner list and list of valid status values. thanks I know how to this sort of thing with RAW SQL but prefer to try to use the API. I have looked at QueueSummaryByStatus in RT4 but thanks On Thu, 12 Jul 2012, Kevin Falcone wrote: Date: Thu, 12 Jul 2012 15:00:00 -0400 From: Kevin Falcone falc...@bestpractical.com Reply-To: rt-users@lists.bestpractical.com To: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 07:43:16PM +0100, Richard McMahon wrote: I am doing some ASCII perl reports and one of the options is to supply the queue name. I want to be able to get a list of the queues that are available as an input check. In that case, it's probably easier to -Load the queue by name and see if it exists, rather than list 20 queues and name compare each. -kevin On Thu, 12 Jul 2012, Ruslan Zakirov wrote: Date: Thu, 12 Jul 2012 21:30:15 +0300 From: Ruslan Zakirov r...@bestpractical.com To: Richard McMahon r...@ast.cam.ac.uk Cc: rt-users@lists.bestpractical.com Subject: Re: [rt-users] Perl API: list of available queues, owners, status On Thu, Jul 12, 2012 at 7:58 PM, Richard McMahon r...@ast.cam.ac.uk wrote: Hello, Is there a way/example of how to get a list of queues, owners, status using the Perl API? I want to cycle through making a list counts for each owner and queue by status. You want count tickets groupped by queue, owner and status, right? You really don't want to iterate over anything. It will be very slow. Instead take a look at how QueueSummaryBy* files do it in RT 4.0 and how RT::Extension::SummaryByUser (on CPAN) does similar task. You just need to combine two tables into one big table. --- Dr. Richard G. McMahon| Phone (office) 44-(0)-1223-337519 University of Cambridge | (switchboard) 1223-337548 Institute of Astronomy| (secretary) 1223-337516 Madingley Rd | FAX 1223-337523 Cambridge, CB3 OHA, UK. | mobile7885-409019 Office: Hoyle 18 | home 1223-359770 --- email: r...@ast.cam.ac.uk | WWW:http://www.ast.cam.ac.uk/~rgm richardgmcma...@gmail.com | skype:richardgmcmahon --- pgp3ADpFooG5h.pgp Description: PGP signature