First arg is the PR number you want to change, second is the field you want to add/change, and third is the new value you want. There's an optional 4th argument of a "change reason" in case your GNATS requires a reason for that field change.
I'll make a tracker item to add specific documentation fo this in the perldoc, as well as an example in the eg.pl script. It might also be a good idea for an 'updatePR()' method which takes a Net::Gnats::PR object as argument.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for replying ...
Ya, it should be a good idea, because, I'm working with GNATS for more than one year now ... And, my main job ( except doing backups ) is to run some massive updates, for example : Close a list of PR, updating the Closed-Date, Last-Modified & the Audit-train ...
This is very usefull ... Actually, I do it by a shell script, but it's a little bit slow ... :)
Let me try again the "replaceField" function ... I'll post a feedback and if you are interresting in, a perl example script for massive updates.
Best Regards
Arnaud
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is the sample script I'm trying to make work :) :
+++++++++++++++++++++++
my $g = Net::Gnats->new();
$g->connect();
$g->login("default","user","passwd");
my $PRNum = 1;
$g->lockPR($PRNum,"user") or die "Some Comments ...";
$g->replaceField($PRNum,"Environment","Replacement value ... ") or die "Some other comments ... ";
$g->unlockPR($PRNum);
$g->disconnect();
+++++++++++++++++++++++
This doesn't work ... I guess it's because the PR is locked ...
Trying without lockPR/unlockPR statements :
No more error messages, but the PR is not changed ...
Any idea ?
Thanks again ...
Arnaud
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Glad you got it working. As for the large attachments, I'm afraid I haven't tested Net::Gnats with attachments, so the code might not handle them well. I'll add a bug report in the tracker, and see if anything can be done to speed it up.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well I've got here at home an export of the gnats db I manage at work. It's arround 2200PR (15MB).
When I've made the tests last night, I forgot to update the dbconfig file to match the one we use :)
So I'll test it soon ( right now it's time to go to sleep ) ...
May be the problem is with my index ... And perhaps I'm a very poor developer :)
Arnaud
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Come on, Arnaud, where's that programmer's hubris? ;)
Net::Gnats currently works by setting all fields of a PR immediatlely when 'getPRByNumber' is called. The entire PR text is received from gnatsd, and Net::Gnats parses this text and puts the individual fields in a hash. Attachments are included in this (they're text-encoded and listed in the 'Unformatted' field)
There are a couple of performance issues here, then: a) potentially high memory usage and b) regexps performed on possibly very large strings (PR attachments). Although I think the regexps/memory usage could be made somewhat more efficient, the PR is a container object, thus it may very well use up a lot of memory.
So, basically, I think if you actually NEED all the data from every PR in your database, you may have to live with some processing delay (maybe not as much as Net::Gnats currently takes, but parsing 15MB of text will take SOME time...). However, if you DON'T need all the fields, then unfortunately Net::Gnats is forcing you to wait for data you don't need, and that is bad.
This tells me Net::Gnats should provide some way to not get ALL fields from a PR (for example, "get me PR 28, but only the fields 'Synpopsis,' 'Submitter'.."). This would prevent having to wait for unneeded data. I'll see about adding this soon.
Ok, so, assuming you don't actually need the attachments, and you want some subset of the fields, here is a workaround you can use to get a subset of the fields. This will make your code a bit more ugly, but it should be the quickest and most efficient way to avoid pulling hte attachments from the PR.
So, let's say you want PR #37 from teh database, and you only want the field "Synopsis". You could use the following code:
$response should contain the text of the synopis field for PR 37. You would have to repeat this code (including the RSET call) for each field you wanted. Of course, you could use variables for the field name and PR number.
Ok, I hope there are some pointers/ideas here you can use. Let me know if you need any further help. Good luck.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems that solve my performance problem
I have notice that :
If you are querying for a Date Value The output is in "UNIX Time Format" but, I dont care, some regex will solve this :)
I'll let you know about the results of my tests in a few days ...
Have a nice Week End
Arnaud
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mike,
I'm trying to use your perl module to manage a Gnats Database especially massive updates.
I've spent some time, reading, re-reading the documentation, making many tests ... Everything seem working fine with GNATS 4 & 3 ...
But I haven't find any way to modify the value of one field in a PR.
Any idea ?
May be this feature is not implemented yet :) ...
If I can help you for testing ... let me know
Hi,
You should be able to make changes to a PR. The Net::Gnats::replaceField method should do what you need. The general idea is:
$g->replaceField($PRNum, "Fix","The replacement value");
First arg is the PR number you want to change, second is the field you want to add/change, and third is the new value you want. There's an optional 4th argument of a "change reason" in case your GNATS requires a reason for that field change.
I'll make a tracker item to add specific documentation fo this in the perldoc, as well as an example in the eg.pl script. It might also be a good idea for an 'updatePR()' method which takes a Net::Gnats::PR object as argument.
Mike
Hi Mike,
Thanks for replying ...
Ya, it should be a good idea, because, I'm working with GNATS for more than one year now ... And, my main job ( except doing backups ) is to run some massive updates, for example : Close a list of PR, updating the Closed-Date, Last-Modified & the Audit-train ...
This is very usefull ... Actually, I do it by a shell script, but it's a little bit slow ... :)
Let me try again the "replaceField" function ... I'll post a feedback and if you are interresting in, a perl example script for massive updates.
Best Regards
Arnaud
Just for information :
Here is the sample script I'm trying to make work :) :
+++++++++++++++++++++++
my $g = Net::Gnats->new();
$g->connect();
$g->login("default","user","passwd");
my $PRNum = 1;
$g->lockPR($PRNum,"user") or die "Some Comments ...";
$g->replaceField($PRNum,"Environment","Replacement value ... ") or die "Some other comments ... ";
$g->unlockPR($PRNum);
$g->disconnect();
+++++++++++++++++++++++
This doesn't work ... I guess it's because the PR is locked ...
Trying without lockPR/unlockPR statements :
No more error messages, but the PR is not changed ...
Any idea ?
Thanks again ...
Arnaud
oupps :)
Finally, it works ...
Just remove from the previous script the LOCK/UNLOCK Statements ...
Best Regards
Just one more thing for your information ...
When I make a "getPRByNumber" on a very big PR ( ie: a PR which has one or more file in attachment -- from gnatsweb -- size 1,5MB ) ...
It take more than 2 minutes to extract a Field Value ( with "getField" ) ... And I saw that the CPU is 100% ...
Best regards
Arnaud
Arnaud,
Glad you got it working. As for the large attachments, I'm afraid I haven't tested Net::Gnats with attachments, so the code might not handle them well. I'll add a bug report in the tracker, and see if anything can be done to speed it up.
Mike
Hi Mike,
Well I've got here at home an export of the gnats db I manage at work. It's arround 2200PR (15MB).
When I've made the tests last night, I forgot to update the dbconfig file to match the one we use :)
So I'll test it soon ( right now it's time to go to sleep ) ...
May be the problem is with my index ... And perhaps I'm a very poor developer :)
Arnaud
Come on, Arnaud, where's that programmer's hubris? ;)
Net::Gnats currently works by setting all fields of a PR immediatlely when 'getPRByNumber' is called. The entire PR text is received from gnatsd, and Net::Gnats parses this text and puts the individual fields in a hash. Attachments are included in this (they're text-encoded and listed in the 'Unformatted' field)
There are a couple of performance issues here, then: a) potentially high memory usage and b) regexps performed on possibly very large strings (PR attachments). Although I think the regexps/memory usage could be made somewhat more efficient, the PR is a container object, thus it may very well use up a lot of memory.
So, basically, I think if you actually NEED all the data from every PR in your database, you may have to live with some processing delay (maybe not as much as Net::Gnats currently takes, but parsing 15MB of text will take SOME time...). However, if you DON'T need all the fields, then unfortunately Net::Gnats is forcing you to wait for data you don't need, and that is bad.
This tells me Net::Gnats should provide some way to not get ALL fields from a PR (for example, "get me PR 28, but only the fields 'Synpopsis,' 'Submitter'.."). This would prevent having to wait for unneeded data. I'll see about adding this soon.
Ok, so, assuming you don't actually need the attachments, and you want some subset of the fields, here is a workaround you can use to get a subset of the fields. This will make your code a bit more ugly, but it should be the quickest and most efficient way to avoid pulling hte attachments from the PR.
So, let's say you want PR #37 from teh database, and you only want the field "Synopsis". You could use the following code:
my ($code, $response) = $g->_doGnatsCmd("RSET");
($code, $response) = $g->_doGnatsCmd("QFMT Synopsis");
($code, $response) =$g->_doGnatsCmd("QUER 37");
print $response;
$response should contain the text of the synopis field for PR 37. You would have to repeat this code (including the RSET call) for each field you wanted. Of course, you could use variables for the field name and PR number.
Ok, I hope there are some pointers/ideas here you can use. Let me know if you need any further help. Good luck.
Mike
Thanks Mike ...
Let me some time to try your "workaround" ... ;)
It seems that solve my performance problem
I have notice that :
If you are querying for a Date Value The output is in "UNIX Time Format" but, I dont care, some regex will solve this :)
I'll let you know about the results of my tests in a few days ...
Have a nice Week End
Arnaud