package RPS::ArtistRoyalty::Fast::Static::ContractTracks;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/rps/lib';
use lib '/app/tools/raptor/lib';
use Common::RSApp;

use Common::Log;

# We do not need to use Berkeley DB here since we are not going to change the content.
# Let's just cache all existing contracts for track records.

sub GetContractTracksData {
    my $class = shift;

    my $dbo = Common::RSApp::GetClientDB();

    my $sql = qq/
        SELECT
            tc.artist_contract_id,
            tc.track_id
        FROM track_contract AS tc
        LEFT JOIN new_artist_contract AS nac USING(artist_contract_id)
        WHERE nac.deleted = 0
    /;
    my $sth = $dbo->DoCmd($sql);

    my %contractTrackMap;
    while ( my @data = $sth->fetchrow_array() ) {
        $contractTrackMap{ "$data[0]|$data[1]" } = undef;
    }

    return \%contractTrackMap;
}


1;