/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $inputStart = $input->getArgument('start'); $inputEnd = $input->getArgument('end'); $startTime = new DruidTime($inputStart); $endTime = new DruidTime($inputEnd); $formattedStartTime = $startTime->formatTimeForDruid(); $formattedEndTime = $endTime->formatTimeForDruid(); $output->write("<info>Ingesting data</info>"); if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->write(" for the period <info>{$formattedStartTime}</info> to <info>{$formattedEndTime}</info>"); } $output->write("\n"); $this->ingest($formattedStartTime, $formattedEndTime, $input, $output); }
public function testCanSetWithAnotherDruidTime() { $dtA = new DruidTime('2014-01-02T00:20'); $interval = new DruidTime($dtA); $this->assertEquals('2014-01-02T00:20:00Z', $interval->formatTimeForDruid()); }
/** * Process an item in the fetched items array * * @param $row * @return mixed */ protected function processRow($row) { // todo could fail here ..needs exception! $timeForDruid = new DruidTime($row['date']); $row['date'] = $timeForDruid->formatTimeForDruid(); return $row; }
/** * Bind the start and end ingestion date windows to a query. * * @param String $query Query with {STARTDATE} and {ENDDATE} for value substituion * @param String $start ISO Date Time string * @param String $end ISO Date Time string * @return String Prepared query string */ public function prepareQuery($query, DruidTime $start, DruidTime $end) { $startTime = new DruidTime($start); $endTime = new DruidTime($end); $formattedStartTime = $startTime->formatTimeForDruid(); $formattedEndTime = $endTime->formatTimeForDruid(); $preparedQuery = $query; $preparedQuery = str_replace('{STARTDATE}', $formattedStartTime, $preparedQuery); $preparedQuery = str_replace('{ENDDATE}', $formattedEndTime, $preparedQuery); return $preparedQuery; }