Skip to content

Commit

Permalink
3.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Nick Georgieff committed Nov 8, 2017
1 parent bef3ba8 commit e72213d
Show file tree
Hide file tree
Showing 21,108 changed files with 74,641 additions and 2,456,411 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
53 changes: 53 additions & 0 deletions bin/fix_task.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env perl

use MongoDB;
use Data::Dumper;
use v5.18;

my $mongo = MongoDB->connect->db('scot-prod');
my $collection = $mongo->get_collection('entry');
my $cursor = $collection->find({class => "task"});

print "starting...\n";
print $cursor->count . " task records\n";
my %lookup = ();

while (my $task = $cursor->next) {

my $id = $task->{id};
print "...task $id\n";

my $meta = $task->{metadata};

if ( defined $meta ) {

if ( defined $meta->{status}
&& defined $meta->{when}
&& defined $meta->{who} ) {

say "... ... has valid task meta structure";

my $thref = {
status => $meta->{status},
when => $meta->{when},
who => $meta->{who},
};

delete $meta->{status};
delete $meta->{when};
delete $meta->{who};

$meta->{task} = $thref;

my $set = {
metadata => $meta
};

$collection->update_one(
{id => $id},
{'$set' => $set }
);
say "Update == ".Dumper($set);
}
}
}
1 change: 1 addition & 0 deletions install/src/mongodb/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ db.signature.drop();
db.sigbody.drop();
db.apikey.drop();
db.handler.drop();
db.stat.drop();

print ("Creating indexes...");
load("./src/mongodb/indexes.js");
Expand Down
5 changes: 5 additions & 0 deletions install/src/scot/scot.cfg.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
log_level => 'DEBUG',
},

cgi_ids_config => {
whitelist_file => '',
disable_filters => [],
},

# modules to instantiate at Env.pm startup. will be done in
# order of the array
modules => [
Expand Down
63 changes: 49 additions & 14 deletions lib/Scot/App/Flair.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,36 @@ sub _get_img_munger {
return $env->img_munger;
};

#has scot => (
# is => 'ro',
# isa => 'Scot::Util::Scot2',
# required => 1,
# lazy => 1,
# builder => '_build_scot_scot',
#);

#sub _build_scot_scot {
# my $self = shift;
# my $env = shift;
# return $env->scot;
#}
has stomp_host => (
is => 'ro',
isa => 'Str',
required => 1,
lazy => 1,
builder => '_build_stomp_host',
);

sub _build_stomp_host {
my $self = shift;
my $attr = "stomp_host";
my $default = "localhost";
my $envname = "scot_util_stomphost";
return $self->get_config_value($attr, $default, $envname);
}
has stomp_port => (
is => 'ro',
isa => 'Int',
required => 1,
lazy => 1,
builder => '_build_stomp_port',
);

sub _build_stomp_port {
my $self = shift;
my $attr = "stomp_port";
my $default = 61613;
my $envname = "scot_util_stompport";
return $self->get_config_value($attr, $default, $envname);
}

has interactive => (
is => 'ro',
Expand Down Expand Up @@ -156,7 +173,14 @@ sub run {
my $self = shift;
my $log = $self->log;
my $pm = AnyEvent::ForkManager->new(max_workers => $self->max_workers);
my $stomp = AnyEvent::STOMP::Client->new();
my $stomp;

if ( $self->stomp_host ne "localhost" ) {
$stomp = AnyEvent::STOMP::Client->new($self->stomp_host, $self->stomp_port);
}
else {
$stomp = AnyEvent::STOMP::Client->new;
}

$stomp->connect();
$stomp->on_connected(sub {
Expand Down Expand Up @@ -384,6 +408,7 @@ sub flair_record {

if ( $column =~ /^message[_-]id$/i ) {
# the data is telling us that this is a email message_id, so flair
$value =~ s/[\<\>]//g; # cut out the < > brackets if they exist
my ($eref, $flair) = $self->process_cell($value, "message_id");
if ( ! defined $seen{$eref->{value}} ) {
push @entity, $eref;
Expand All @@ -409,7 +434,15 @@ sub flair_record {
# each link in this field is a <div>filename</div>,
$log->debug("A File attachment Column detected!");
$log->debug("value = ",{filter=>\&Dumper, value=>$value});

if ( $value eq "" || $value eq " " ) {
next VALUE;
}

if ( $value eq "" || $value eq " " ) {
next VALUE;
}

my ($eref, $flair) = $self->process_cell($value, "filename");
if ( ! defined $seen{$eref->{value}} ) {
push @entity, $eref;
Expand Down Expand Up @@ -464,6 +497,8 @@ sub process_cell {
my $log = $self->env->log;

$log->debug("text = $text");
$text = encode_entities($text);
$log->debug("encoded text = $text");
$log->debug("header = $header");
my $flair = $self->genspan($text,$header);
$log->debug("text = $text");
Expand Down
45 changes: 42 additions & 3 deletions lib/Scot/App/Stretch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,37 @@ sub _get_max_workers {
return $self->get_config_value($attr, $default, $envname);
}

has stomp_host => (
is => 'ro',
isa => 'Str',
required => 1,
lazy => 1,
builder => '_build_stomp_host',
);

sub _build_stomp_host {
my $self = shift;
my $attr = "stomp_host";
my $default = "localhost";
my $envname = "scot_util_stomphost";
return $self->get_config_value($attr, $default, $envname);
}
has stomp_port => (
is => 'ro',
isa => 'Int',
required => 1,
lazy => 1,
builder => '_build_stomp_port',
);

sub _build_stomp_port {
my $self = shift;
my $attr = "stomp_port";
my $default = 61613;
my $envname = "scot_util_stompport";
return $self->get_config_value($attr, $default, $envname);
}

=head2 Autonomous
$stretch->run();
Expand All @@ -112,7 +143,15 @@ sub run {
$log->debug("Starting STOMP watcher");
$log->debug("SCOT access mode is ".$self->scot_get_method);

my $stomp = AnyEvent::STOMP::Client->new();
my $stomp;

if ( $self->stomp_host eq "localhost" ) {
$stomp = AnyEvent::STOMP::Client->new();
}
else {
$stomp = AnyEvent::STOMP::Client->new($self->stomp_host, $self->stomp_port);
}

my $pm = AnyEvent::ForkManager->new(
max_workers => $self->max_workers
);
Expand Down Expand Up @@ -182,7 +221,7 @@ sub process_message {
my $cleanser = Data::Clean::FromJSON->get_cleanser;
my $record = $self->get_document($type, $id);
$cleanser->clean_in_place($record);
$es->index($type, $record, 'scot');
$es->index('scot', $type, $record);
$self->put_stat("elastic doc inserted", 1);
}

Expand Down Expand Up @@ -291,7 +330,7 @@ sub process_all {

delete $href->{_id};
try {
$es->index($collection, $href, 'scot');
$es->index('scot',$collection, $href);
}
catch {
say "Error: Failed to index $collection : ". $href->{id};
Expand Down
13 changes: 11 additions & 2 deletions lib/Scot/Collection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ has env => (
default => sub { Scot::Env->instance; },
);



=item B<create(%args)>
replacing Meerkat's create with one that will generate a integer id.
Expand Down Expand Up @@ -518,7 +520,8 @@ sub api_list {

if ( $href->{task_search} ) {
# $match->{'task.status'} = {'$exists' => 1};
$match->{'metadata.status'} = {'$exists' => 1};
# $match->{'metadata.status'} = {'$exists' => 1};
$match->{class} = "task";
}

$self->env->log->debug("match is ",{filter=>\&Dumper, value=>$match});
Expand Down Expand Up @@ -624,7 +627,13 @@ sub api_find {
my $obj = $self->find_iid($id);
return $obj;
}
my $id = $href->{id} + 0;
my $id = $href->{id};
if ( $id eq "undefined" ) {
$id = 0;
}
else {
$id += 0;
}
my $obj = $self->find_iid($id);
return $obj;

Expand Down
3 changes: 2 additions & 1 deletion lib/Scot/Collection/Apikey.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ override api_list => sub {
my $req = shift;
my $user = shift;
my $groups = shift;
my $env = $self->env;

my $match = $self->build_match_ref($req->{request});

if (! $self->env->is_admin($user,$groups) ) {
if (! $env->is_admin($user,$groups) ) {
$match->{username} = $user;
}
my $cursor = $self->find($match);
Expand Down
2 changes: 1 addition & 1 deletion lib/Scot/Collection/Audit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sub create_audit_rec {
groups => $handler->session('groups'),
when => $self->env->now,
method => $req->method,
url => $req->url->to_abs,
url => $req->url->to_abs->to_string,
from => $handler->tx->remote_address,
agent => $req->headers->user_agent,
params => $req->params->to_hash,
Expand Down
Loading

0 comments on commit e72213d

Please sign in to comment.