[REFACTOR] Added support for specifying a query and a daily/monthly option at the backend script