changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[ljcom] r6979: LJSUP-3613: stored notification for chan...

Committer: ssafronova
LJSUP-3613: stored notification for changed profiles

U   trunk/bin/upgrading/update-db-local.pl
U   trunk/cgi-bin/LJ/Hooks/EventsFeed.pm
A   trunk/htdocs/misc/changed_profiles.bml
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2009-01-15 09:00:08 UTC (rev 6978)
+++ trunk/bin/upgrading/update-db-local.pl	2009-01-15 10:48:01 UTC (rev 6979)
@@ -1100,6 +1100,18 @@
 TYPE = InnoDB
 EOC
 
+## 
+## Stores the list of changed profiles  
+##
+register_tablecreate("changed_profiles_list", <<'EOC');
+CREATE TABLE changed_profiles_list (
+    username  char(15),
+    modified  int unsigned,
+    KEY (modified)
+)
+TYPE = InnoDB
+EOC
+
 register_alter(sub {
 
     unless (column_type("sup_sponsors", "decline_duration")) {

Modified: trunk/cgi-bin/LJ/Hooks/EventsFeed.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/EventsFeed.pm	2009-01-15 09:00:08 UTC (rev 6978)
+++ trunk/cgi-bin/LJ/Hooks/EventsFeed.pm	2009-01-15 10:48:01 UTC (rev 6979)
@@ -61,6 +61,13 @@
     LJ::EventsFeed::ProfileSave->new($u)->fire;
 });
 
+LJ::register_hook('profile_save', sub {
+    my $u = shift;
+    my $dbh = LJ::get_db_writer();
+    $dbh->do("INSERT IGNORE INTO changed_profiles_list (username, modified) VALUES (?, UNIX_TIMESTAMP())",
+             undef, $u->user);
+});
+
 LJ::register_hook('rename_user', sub {
     my ($u, $newlogin) = @_;
     LJ::EventsFeed::UserRename->new($u, $newlogin)->fire;

Added: trunk/htdocs/misc/changed_profiles.bml
===================================================================
--- trunk/htdocs/misc/changed_profiles.bml	                        (rev 0)
+++ trunk/htdocs/misc/changed_profiles.bml	2009-01-15 10:48:01 UTC (rev 6979)
@@ -0,0 +1,26 @@
+<?_code
+{
+    use strict;
+    use vars qw(%GET);
+    use LJ::Syndi;
+
+    BML::set_content_type('text/plain; charset=utf-8');
+    BML::finish();
+    BML::noparse();
+
+    my $since = $GET{since} + 0;
+    $since ||= 0;
+    my $last = $since;
+
+    my $limit = 5000;
+
+    my $dbh = LJ::get_db_writer();
+    $dbh->do("DELETE FROM changed_profiles_list WHERE modified + 86400 < unix_timestamp()");
+    
+    my $usernames = $dbh->selectall_arrayref("SELECT username, modified FROM changed_profiles_list "
+                                             . "WHERE modified >= ? ORDER BY modified LIMIT $limit", undef, $since);
+    $last = $usernames->[-1]->[1] if scalar @$usernames;
+
+    return "#last timestamp: $last\n" . join("\n", map { $_->[0] } @$usernames);
+}
+_code?>

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments