# Artist Sync Data Prep

## Introduction

The reason this script exists is to create a Kinesis payload that can be
consumed by the [lambda-artist-info-sync](https://github.com/theorchard/lambda-artist-info-sync)
lambda. For more on what this lambda does, please see the repo. There are cases
when the lambda does not populate the data correct, and that is why we sometimes
need to run this script and manually do the artist data sync manually.

This is a script that will retrieve all release, track, and writer data for a
given set of UPCs. The output is formatted as a Kinesis payload that can be
copied into the lambda.

## Setup

This script is written in Ruby (see note below), so please make sure you have a current version
of Ruby installed. Version 2.6.x should work fine. You will also likely need to have
MySQL installed as the MySQL connector will require libraries to compile.

Copy or rename `.env.sample` to `.env` and add your username and password for the
art_relations database host specified in that file (reportsar or reportsar02
most likely).

If you have bundler already installed, you can run `bundle install` to install
the required rubygems. If you don't have bundler installed already install it by
typing `gem install bundler`. After the gems are installed, you're ready to go.

_**NOTE**: I wrote this in Ruby because it was much quicker for me than Python.
And I assumed this was a short-term situation._

## Usage

The script takes a list of comma separated upcs as a single argument and it
outputs the kinesis payload to your Mac clipboard using pbcopy. You can then
paste that into your local version of the lambda code. The usage is:

`
ruby prep_data.rb <list of upcs>
`

Example:

`
ruby prep_data.rb 192562976845,192562670132,192562394625
`

Output:

`
Results are on the clipboard
`

