Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start API to get zone history as JSON

  • Loading branch information...
commit fc8270a10118ef0732859338b05af635459009c9 1 parent 90b37de
@abh authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/NTPPool/Control/Zone.pm
View
21 lib/NTPPool/Control/Zone.pm
@@ -3,10 +3,11 @@ use strict;
use base qw(NTPPool::Control);
use NP::Model;
use Combust::Constant qw(OK);
+use JSON qw(encode_json);
sub zone_name {
my $self = shift;
- my ($zone_name) = ($self->request->uri =~ m!^/zone/(?:graph/)?([^/]+?)(/|(-v6)?\.png)?$!);
+ my ($zone_name) = ($self->request->uri =~ m!^/zone/(?:graph|json/)?([^/]+?)(/|(-v6)?\.png)?$!);
$zone_name ||= '.';
$zone_name;
}
@@ -63,6 +64,24 @@ sub render {
$self->cache_control('max-age=10800, s-maxage=7200');
return OK, $fh, 'image/png';
}
+ elsif ($self->request->path =~ m!^/zone/json!) {
+ my $data = NP::Model->zone_server_count->get_objects(
+ query => [zone_id => $zone->id],
+ sort_by => 'date',
+ limit => 3000,
+ );
+
+ my @data = map {
+ +{ d => $_->date->date,
+ ac => $_->count_active,
+ rc => $_->count_registered,
+ w => $_->netspeed_active,
+ iv => $_->ip_version,
+ }
+ } @$data;
+
+ return OK, encode_json(\@data), 'application/json';
+ }
$self->tpl_param('zone' => $zone);

0 comments on commit fc8270a

Please sign in to comment.
Something went wrong with that request. Please try again.