#!/bin/bash

set -xe

if [ "$DAYS" = "0" ]; then
date1=$(date -d "-$SKIP days" +"%s")
for VARIABLE in 0 1 2 3
do
	date2=$(date -d "$VARIABLE months ago - $SKIP days" +"%s")
	diff=$(($date1-$date2))
	new_skip=$(($diff/(60*60*24)+$SKIP+1))
	python feed_ingestion/bin/exec_flows.py deezer_marketshare --skip $new_skip --days "1" --check-status --context "{\"reload\": \"True\"}"
done
else # for standard launch
python feed_ingestion/bin/exec_flows.py deezer_marketshare --skip $SKIP --days $DAYS --check-status --context "{\"reload\": \"True\"}"
fi
