#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::LabelRoyalty::Job::CommitLabelRoyaltyRun;

use strict;
use warnings;
use Sys::Hostname;

use lib '/app/tools/common/lib';
use Common::Log;
use Common::Assert;
use Common::RSApp;
use Common::SlackURLs;

use lib '/app/tools/rps/lib';
use RPS::Config;

use lib '/app/tools/job/lib';
use Job::Job;

use base 'Job::Job';

use constant kJobClass => 'CommitLabelRoyaltyRun';

sub _generateCommandLine {
    my ($self) = @_;

    my $runID = $self->getCommandLineArg('runID');
    assert($runID);

    my $clientID = $self->clientID();

    my $logLevel = $self->getCommandLineArg('logLevel');
    $logLevel = 2 unless $logLevel;

    my $config     = RPS::Config->new();
    my $scriptPath = $config->get('royalty_script_dir');

    my $commandLine = "nice $scriptPath/commit_label_royalty_run.pl -c $clientID -r $runID -V $logLevel";

    return $commandLine;
}

sub _defaultClass    { return 'RunUtility'; }
sub _defaultSubclass { return 'CommitLabelRoyaltyRun'; }
sub _defaultPriority { return Job::Job::kPriorityHigh; }


### Slack notification config
#
# This endpoint currently supports three variables:
# ClientName, JobURL, and JobType
# The first two are added in by the base class,
# so we just need to set JobType here.

sub _notifyFailureVariables {
    my $self      = shift;
    my %variables = ( JobType => "Commit Label Royalty Run" );
    return %variables;
}

sub _notifyFailureURL {
    my $self = shift;
    return Common::SlackURLs::kRoyaltyRunErrors;
}

sub _notifyFailureTestURL {
    my $self = shift;
    return Common::SlackURLs::kRoyaltyRunErrorsTest;
}

###
1;    #
###

