afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-09-05 12:13 pm

[dw-free] birthday sort order needs fixing

[commit: http://hg.dwscoalition.org/dw-free/rev/c7dfa9c29068]

http://bugs.dwscoalition.org/show_bug.cgi?id=1610

Put birthdays back on the list of upcoming birthdays, if their notifications
have already been sent.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/User/Edges/WatchTrust.pm
--------------------------------------------------------------------------------
diff -r ee7de5f9dd15 -r c7dfa9c29068 cgi-bin/DW/User/Edges/WatchTrust.pm
--- a/cgi-bin/DW/User/Edges/WatchTrust.pm	Sat Sep 05 11:33:28 2009 +0000
+++ b/cgi-bin/DW/User/Edges/WatchTrust.pm	Sat Sep 05 12:12:35 2009 +0000
@@ -400,6 +400,19 @@ sub get_birthdays {
     # hash slice for array sorted by date
     my @bdays = @timedata{ sort keys %timedata };
 
+    # birthdays that have already had notifications sent
+    # are sorted to the end, so check for those and rewrap
+    while ( my $last = pop( @bdays ) ) {
+        if ( ( $last->[0] == $mnow &&   # this month
+               $last->[1] >= $dnow ) || # today or later
+             ( $last->[0] == ( $mnow % 12 ) + 1 ) ) {  # next month
+            unshift( @bdays, $last );
+        } else {  # put it back and exit
+            push( @bdays, $last );
+            last;
+        }
+    }
+
     # set birthdays in memcache for later
     LJ::MemCache::set($memkey, \@bdays, 86400);
 
--------------------------------------------------------------------------------