From: Robert Lupton the Good <rhl@astro.Princeton.EDU>
To: help-gnats@gnu.org
Subject: Patch for gnatsweb.pl
Date: Fri, 27 Sep 2002 00:32:00 -0000 [thread overview]
Message-ID: <15763.3642.610545.301933@wire7.Princeton.EDU> (raw)
In-Reply-To: <20020925181413.GA1154909@cluster2.netman.dk>
I don't think that I ever posted my custom sort routine. Thinking
about it, this might go better in gnatsweb.pl itself, as the custom
sort itself uses cb('sort_keys') for customization.
R
elsif ($reason eq 'sort_keys')
{
return qw(Severity Priority Class State Category Scheduled);
}
elsif ($reason eq 'sort_query')
{
my($sortby) = shift @args;
if(defined($sortby) && $sortby eq "custom") {
if($args[0] ne 'checking_if_custom_sort_exists') {
my(@fields) = $q->param('columns');
#
# Sort by these fields in this order; PR is always added
# as a final key. We'll start by figuring out which
# field is which, and whether they are numeric or string valued
#
my(@sort_keys) = cb('sort_keys');
my($field, $i, @keys);
my($whichfield) = 1; # field counter (0 is PR)
for $field (@fields) {
$field = param2field($field);
$i = 0;
foreach (@sort_keys) {
if($_ eq $field) {
my $fieldtype =
fieldinfo($field, 'fieldtype') || '';
$keys[$i] = {};
$keys[$i]->{field} = $field;
$keys[$i]->{i} = $whichfield;
if ($fieldtype eq 'enum' ||
$fieldtype eq 'integer') {
$keys[$i]->{cmp} = "<=>"
} else {
$keys[$i]->{cmp} = "cmp";
}
}
$i++;
}
$whichfield++;
}
#
# OK, @keys is now an array telling us how to sort.
# Generate the sort BLOCK
#
my($sort_block) = "";
for (@keys) {
if(defined($_->{field})) {
$sort_block .=
" \$a->[$_->{i}] $_->{cmp} \$b->[$_->{i}] or \# $_->{field}\n";
}
}
$sort_block .= " \$a->[0] <=> \$b->[0]; \# PR\n";
my($debug) = 0;
if($debug) {
print_header();
print "<BR>sort_block: <PRE>$sort_block</PRE>\n";
}
eval "\@args = sort({ $sort_block } \@args)";
if($@) {
print $@;
}
}
return @args;
} else {
return undef;
}
}
_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats
next prev parent reply other threads:[~2002-09-26 13:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-16 6:48 Robert Lupton the Good
2002-09-17 9:47 ` Yngve Svendsen
2002-09-23 12:22 ` Lars Henriksen
2002-09-25 11:18 ` Lars Henriksen
2002-09-25 11:43 ` Yngve Svendsen
2002-09-25 13:13 ` Lars Henriksen
2002-09-26 15:46 ` Robert Lupton the Good
2002-09-27 0:32 ` Robert Lupton the Good [this message]
2002-09-30 2:07 ` Lars Henriksen
[not found] <20020915103254.22538.88942.Mailman@monty-python.gnu.org>
2002-09-16 6:56 ` Robert Lupton the Good
2002-09-16 7:24 ` patch " Robert Lupton the Good
2002-09-16 7:45 ` Robert Lupton the Good
-- strict thread matches above, loose matches on Subject: below --
2002-09-16 6:46 Patch " Robert Lupton the Good
2001-09-06 14:09 patch " David, Lysander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15763.3642.610545.301933@wire7.Princeton.EDU \
--to=rhl@astro.princeton.edu \
--cc=help-gnats@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).