Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 313548 Details for
Bug 457699
replace NEEDINFO status in saved queries with needinfo flag
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
v1 script to replace NEEDINFO with needinfo? in saved queries
update_needinfo_queries.pl (text/plain), 4.44 KB, created by
Noura El hawary
on 2008-08-06 10:29:36 UTC
(
hide
)
Description:
v1 script to replace NEEDINFO with needinfo? in saved queries
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-08-06 10:29:36 UTC
Size:
4.44 KB
patch
obsolete
>#!/usr/bin/env perl >use strict; >use warnings; > ># script: update_needinfo_queries.pl ># descr: one time script to replace NEEDINFO status with needinfo flag ># in the saved queries ># BZ: https://bugzilla.redhat.com/show_bug.cgi?id=457699 > >use DBI; >use CGI; > >my $log_file = 'needinfo_status_log2'; >open LOGFILE, '>>', $log_file > or die "couldn't open $log_file: $!"; > >if (@ARGV) { > my $cmdline_query = shift @ARGV; > > convert_query($cmdline_query); >} >else { > > my $user_mysql = ''; > my $pass_mysql = ''; > my $host_mysql = ''; > > my %attr = ( > PrintError => 0, > RaiseError => 1 > ); > > my $dsn_mysql = "dbi:mysql:dbname=bugs;host=$host_mysql"; > my $dbh = DBI->connect( $dsn_mysql, $user_mysql, $pass_mysql, \%attr ) > or die "Couldn't connect database: " . DBI->errstr; > > my @custom_fields = qw/'%bug_status=NEEDINFO%' '%%2CNEEDINFO%'/; > > my $condition = join( " OR query LIKE ", @custom_fields ); > > my $query > = "SELECT DISTINCT userid, name, query FROM namedqueries WHERE query LIKE $condition"; > > my $count = 0; > > my $select_query_sth = $dbh->prepare($query); > > $select_query_sth->execute(); > while ( my ( $userid, $name, $old_query ) > = $select_query_sth->fetchrow_array() ) > { > my $new_query = convert_query($old_query); > > # Save change to database > my $update_query_sth = $dbh->prepare( > "UPDATE namedqueries SET query = ? WHERE userid = ? AND name = ?" > ); > $update_query_sth->execute( $new_query, $userid, $name ); > print LOGFILE "$userid, $name\n\n"; > $count++; > } > > print LOGFILE "$count converted.\n"; >} > >sub convert_query { > my ($old_query) = @_; > > # Load CGI object with old query string from database > my $cgi = new CGI($old_query); > my @new_products = (); > > print LOGFILE "Old Query: $old_query\n"; > > my @field_no; > my @params = $cgi->param; > > for my $param (@params) { > if ( $param =~ /field\d/ ) { > my @num = $param =~ /field(\d+)/; > push @field_no, @num; > } > } > > @field_no = sort(@field_no); > > my $boolean_chart_count = 0; > $boolean_chart_count = $field_no[$#field_no] + 1 if scalar(@field_no); > > my @bug_statuses = $cgi->param("bug_status"); > my @splitted_statuses = ( split( /,/, $bug_statuses[0] ) ) > if ( ( scalar @bug_statuses ) < 2 ); > @splitted_statuses = @bug_statuses if ( ( scalar @bug_statuses ) > 1 ); > > my $or_boolean_chart_count = 0; > > for my $status (@splitted_statuses) { > > my $field > = "field$boolean_chart_count" . "-0-" . $or_boolean_chart_count; > my $type > = "type$boolean_chart_count" . "-0-" . $or_boolean_chart_count; > my $value > = "value$boolean_chart_count" . "-0-" . $or_boolean_chart_count; > > if ( $status eq 'NEEDINFO' ) { > $cgi->param( -name => $field, -value => "flagtypes.name" ); > $cgi->param( -name => $type, -value => "equals" ); > $cgi->param( -name => $value, -value => "needinfo%3F" ); > } > > else { > $cgi->param( -name => $field, -value => "bug_status" ); > $cgi->param( -name => $type, -value => "equals" ); > $cgi->param( -name => $value, -value => $status ); > > } > > $or_boolean_chart_count++; > > } > > $cgi->delete("bug_status"); > > # Create new query string with update params > my $new_query = canonicalise_query($cgi); > > print LOGFILE "New Query: $new_query\n\n"; > > return $new_query; >} > >sub canonicalise_query { > my ( $cgi, @exclude ) = @_; > > # Reconstruct the URL by concatenating the sorted param=value pairs > my @parameters; > foreach my $key ( sort( $cgi->param() ) ) { > > # Leave this key out if it's in the exclude list > next if lsearch( \@exclude, $key ) != -1; > > my $esc_key = url_quote($key); > > foreach my $value ( $cgi->param($key) ) { > if ($value) { > my $esc_value = url_quote($value); > > push( @parameters, "$esc_key=$esc_value" ); > } > } > } > > return join( "&", @parameters ); >} > >sub url_quote { > my ($toencode) = (@_); > $toencode > =~ s/([^a-zA-Z0-9_\-.%;&?\/\\:=~])/uc sprintf("%%%02x",ord($1))/eg; > return $toencode; >} > >sub lsearch { > my ( $list, $item ) = (@_); > my $count = 0; > foreach my $i (@$list) { > if ( $i eq $item ) { > return $count; > } > $count++; > } > return -1; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 457699
: 313548