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);
 
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org