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

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';

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_artist_royalties.pl -c $clientID -r $runID -V$logLevel";

    return $commandLine;
}

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

# !!! Not going to override the logging stuff.  That can go live in the usual place.
#

### 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 Artist Royalty Run" );
    return %variables;
}

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

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

###
1;    #
###
