#!/usr/bin/perl
#------------------------------------------------------------
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
use strict;

use Getopt::Std;
use Data::Dumper;

use lib '/app/tools/common/lib';

use Common::Log;
use Common::RSApp;
use Common::Client;

use constant kUpdateClientBestSellersScript => 'nice /app/tools/bookpub/bin/best_seller/update_client_best_sellers.pl';

my $appSingleton = Common::RSApp->new( clientID => 0 );

# loop through all product monitoring clients
my $clients = Common::DB::Item::Client->GetAllOfType(Common::Client::kProductMonitoring);
while ( my $client = $clients->next() ) {
    my $clientID = $client->client_id;

    # Fire off the script for each product monitoring client.
    my $command  = kUpdateClientBestSellersScript . " -c $clientID";
    my $exitCode = system($command);
}

