#!/bin/bash

set -xe

context="\"platform_names\":\"$PLATFORM_NAMES\" "

if [ "$WAIT_UNTIL_COMPLETE" = 'true' ] ; then
  	context="${context}, \"wait_until_complete\": \"True\""
fi

if [ "$KAFKA" = 'true' ] ; then
  context="${context}, \"kafka\": \"True\""
fi

if [ "$SKIP_UPDATE_RELATIONS" = 'true' ] ; then
  context="${context}, \"skip_update_relations\": \"True\""
fi

if [ ! -z $DAYS_BACK ]; then
  context="${context},  \"days_back\": \"$DAYS_BACK\""
fi

if [ ! -z $CONTEXT_DATE ]; then
  context="${context},  \"context_date\": \"$CONTEXT_DATE\""
fi

if [ ! -z $CONTEXT_DATE_LIMIT ]; then
  context="${context},  \"context_date_limit\": \"$CONTEXT_DATE_LIMIT\""
fi


echo "{${context}}"

garcon exec chartmetric_charts --context "{${context}}"