[Bps-public-commit] App-Changeloggr branch, master, updated. c8e004d3acaa6a2632758a1a7e57076ef6d25659

sartak at bestpractical.com sartak at bestpractical.com
Tue May 12 00:47:03 EDT 2009


The branch, master has been updated
       via  c8e004d3acaa6a2632758a1a7e57076ef6d25659 (commit)
       via  ad20da5008882f69eaa89a718332606fb4019f8f (commit)
      from  bde313a92ccb166c74528e70da29476ca8555edc (commit)

Summary of changes:
 lib/App/Changeloggr/Model/Change.pm      |   36 ++++++++++++++++++++++++++++++
 lib/App/Changeloggr/OutputFormat/Perl.pm |    8 +++++-
 2 files changed, 43 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit ad20da5008882f69eaa89a718332606fb4019f8f
Author: Shawn M Moore <sartak at gmail.com>
Date:   Tue May 12 00:46:14 2009 -0400

    First stab at Change->numeric_importance

diff --git a/lib/App/Changeloggr/Model/Change.pm b/lib/App/Changeloggr/Model/Change.pm
index fdf86ee..e40285c 100644
--- a/lib/App/Changeloggr/Model/Change.pm
+++ b/lib/App/Changeloggr/Model/Change.pm
@@ -82,5 +82,41 @@ sub external_source {
     return $url;
 }
 
+sub importance_votes {
+    my $self = shift;
+    my $importance_votes = App::Changeloggr::Model::ImportanceCollection->new;
+    $importance_votes->limit( column => 'change_id', value => $self->id );
+    return $importance_votes;
+}
+
+sub numeric_importance {
+    my $self = shift;
+    my $importance_votes = $self->importance_votes;
+
+    $importance_votes->column(
+        column => 'importance',
+    );
+    $importance_votes->column(
+        column   => 'id',
+        function => 'count',
+    );
+    $importance_votes->group_by(
+        column => 'importance',
+    );
+
+    my $numeric_importance = 0;
+
+    while (my $importance_vote = <$importance_votes>) {
+        my $importance = $importance_vote->importance;
+        my $count = $importance_vote->id;
+
+        next if $importance eq 'normal';
+        $numeric_importance += $count if $importance eq 'major';
+        $numeric_importance -= $count if $importance eq 'minor';
+    }
+
+    return $numeric_importance;
+}
+
 1;
 

commit c8e004d3acaa6a2632758a1a7e57076ef6d25659
Author: Shawn M Moore <sartak at gmail.com>
Date:   Tue May 12 00:46:23 2009 -0400

    Order changes in a category by their importance.
    
        We probably want to just filter out any changes that hit some
        low-importance threshold.

diff --git a/lib/App/Changeloggr/OutputFormat/Perl.pm b/lib/App/Changeloggr/OutputFormat/Perl.pm
index c98b262..2bcb737 100644
--- a/lib/App/Changeloggr/OutputFormat/Perl.pm
+++ b/lib/App/Changeloggr/OutputFormat/Perl.pm
@@ -25,7 +25,13 @@ EOT
 
     for my $cat (sort keys %{$args{categories}}) {
         $str .= "\n=head1 $cat\n\n";
-        for my $change (@{$args{categories}{$cat}}) {
+
+        my @changes = map  { $_->[0] }
+                      sort { $a->[1] <=> $b->[1] }
+                      map  { [$_, $_->numeric_importance] }
+                      @{$args{categories}{$cat}}
+
+        for my $change (@changes) {
             my($summary) = $change->message =~ /\A(.*)$/m;
             $str .= "=head2 $summary\n\n" . $change->message . "\n";
         }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list