Первый фоллен на хелле (wildkin) wrote in changelog,
Первый фоллен на хелле
wildkin
changelog

[livejournal] r17896: LJSUP-7240: Endpoint get_day_counts was ...

Committer: dnikolaev
LJSUP-7240: Endpoint get_day_counts was added

A   trunk/htdocs/tools/endpoints/get_day_counts.bml
Added: trunk/htdocs/tools/endpoints/get_day_counts.bml
===================================================================
--- trunk/htdocs/tools/endpoints/get_day_counts.bml	                        (rev 0)
+++ trunk/htdocs/tools/endpoints/get_day_counts.bml	2010-12-10 06:00:03 UTC (rev 17896)
@@ -0,0 +1,35 @@
+<?_code
+{
+    use strict;
+    use LJ::Talk;
+
+    sub error
+    {
+        return LJ::JSON->to_json({ error => $_[0] });
+    }
+
+    use vars qw(%GET %ML);
+
+    return error('Server is down') if $LJ::SERVER_DOWN;
+
+    $GET{journal} =~ s/^3D//;
+    $GET{journal} ||= '';
+    my $u = LJ::load_user($GET{journal}) or return error("Invalid journal: '$GET{journal}'");
+
+    my $counts = {};
+    my $remote = LJ::get_remote();
+    my $days = LJ::get_daycounts($u, $remote);
+    foreach my $day (@$days) {
+        # $day->[3] - count
+        push @{$counts->{$day->[0]}->{$day->[1]}}, $day->[2];
+    }
+
+    BML::set_content_type('text/javascript; charset=utf-8');
+    BML::finish();
+    BML::noparse();
+
+    return LJ::JSON->to_json($counts);
+}
+
+_code?>
+

Tags: bml, livejournal, wildkin
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