List of commits:
Subject Hash Author Date (UTC)
import variable days b9719a68e4a21fbf418b7e82353e48d77e5f0247 Ivaylo Iliev 2017-08-27 22:27:38
update readme e3951190baa0e679f87cf878f1ebfee910be6da2 Ivaylo Iliev 2017-08-27 22:04:18
best month 049d1757e5bab195dbd4374c0f3cba19a263e0e2 Ivaylo Iliev 2017-08-27 22:01:20
best year 9c830895cacc9ae9206901d3eabdc6b21488d718 Ivaylo Iliev 2017-08-27 21:57:46
fix docblock 20f563de5a256acde8c4a2335bf5779c670c61a0 Ivaylo Iliev 2017-08-27 21:22:50
strong typing c5314f47704760d3720f0c92bd3da9e3c7299eea Ivaylo Iliev 2017-08-27 21:15:11
change boolean to bool and add /neo/fastest?hazardous=(true|false) aa0b6fc0d2ab78404e4677863aafae1dd27bead0 Ivaylo Iliev 2017-08-27 21:07:44
fix cases 7fd7024355b538de353f032f69f8e4a1ee5f0b6b Ivaylo Iliev 2017-08-27 20:56:14
/neo/hazardous 61f9c4506a8ddf037f6cd670afdaa4f38f44829c Ivaylo Iliev 2017-08-27 20:54:40
cleanup 98f98692a290d3cd6e76b36e48be6610754640db Ivaylo Iliev 2017-08-27 20:54:24
update nasa.start with parameters 4cec4383b574a0ac874e463cacfc006fb001f14c Ivaylo Iliev 2017-08-27 20:32:01
import from api 41affca95695f99674971d59dc3e098ef54a934b Ivaylo Iliev 2017-08-27 19:34:49
initialize on first run a7eb6521e87bf6f7fc8ac746db7241300473b549 Ivaylo Iliev 2017-08-27 17:26:30
update build scripts 0ca23c79e7f0c2e0a2beae8ea676d1bc6c6c237f Ivaylo Iliev 2017-08-27 16:23:17
neo bundle, neo entity, empty command 5df95da9f7d462e891685b5556abeae1abdd28b4 Ivaylo Iliev 2017-08-27 16:11:31
add mysql 798d32267444f4f26ce9215817720217970c5e06 Ivaylo Iliev 2017-08-27 14:33:00
run and build script a91daf3d789ac334eca951731504f1a17e79952d Ivaylo Iliev 2017-08-27 10:52:34
remove security checks 613463e0180c3e812194b0bac40aaef508d99823 Ivaylo Iliev 2017-08-27 10:52:12
add nasa api key a4f8c147880e69994a988a176298ed54dacc53db Ivaylo Iliev 2017-08-27 08:45:17
hello world json 636f0cca5234693152d25e8a6f7f2e812b39fa16 Ivaylo Iliev 2017-08-27 08:29:56
Commit b9719a68e4a21fbf418b7e82353e48d77e5f0247 - import variable days
Author: Ivaylo Iliev
Author date (UTC): 2017-08-27 22:27
Committer name: Ivaylo Iliev
Committer date (UTC): 2017-08-27 22:27
Parent(s): e3951190baa0e679f87cf878f1ebfee910be6da2
Signing key:
Tree: cdec252c87ee89b747b2ec51b201b04a2d7879b0
File Lines added Lines deleted
src/nasa/src/NeoBundle/Command/ImportVariableDaysCommand.php 19 6
src/nasa/src/NeoBundle/Service/Import.php 9 7
File src/nasa/src/NeoBundle/Command/ImportVariableDaysCommand.php copied from file src/nasa/src/NeoBundle/Command/ImportLastThreeDaysCommand.php (similarity 54%) (mode: 100644) (index c1bd9aa..52c4423)
... ... use Symfony\Component\Console\Input\InputArgument;
10 10 use NeoBundle\Service\Importer; use NeoBundle\Service\Importer;
11 11 use NeoBundle\Exception\NeoImportStructureInvalidException; use NeoBundle\Exception\NeoImportStructureInvalidException;
12 12
13 class ImportLastThreeDaysCommand extends ContainerAwareCommand
13 class ImportVariableDaysCommand extends ContainerAwareCommand
14 14 { {
15 const ARGUMENT_TOTAL_DAYS = 'total-days';
16
15 17 protected function configure() protected function configure()
16 18 { {
17 19 $this $this
18 ->setName('neo:import:lastThreeDays')
19 ->setDescription('Imports last 3 days form nasa api')
20 ->setName('neo:import:variableDays')
21 ->setDescription('Imports variable days form nasa api')
22 ->addArgument(self::ARGUMENT_TOTAL_DAYS, InputArgument::REQUIRED, 'Total days to fetch in the past')
20 23 ; ;
21 24 } }
22 25
23 26 protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
24 27 { {
25 $output->writeln("<info>Import last 3 days from nasa api...</info>");
28 $totalDays = $input->getArgument(self::ARGUMENT_TOTAL_DAYS);
29
30 $output->writeln("<info>Import variable days from nasa api...</info>");
26 31 $output->writeln(""); $output->writeln("");
27 32
28 33 /** @var NeoBundle\Service\Importer $neoImporter */ /** @var NeoBundle\Service\Importer $neoImporter */
29 34 $neoImporter = $this->getContainer()->get('neo.import'); $neoImporter = $this->getContainer()->get('neo.import');
30 35
31 36 try { try {
32 $neoImporter->import();
37 $end = new \DateTime();
38 $start = new \DateTime();
39 $start->sub(new \DateInterval('P' . 1 . 'D'));
40
41 for ($i = 0; $i < $totalDays; $i++) {
42 $neoImporter->import($start, $end);
43 $start->sub(new \DateInterval('P' . 2 . 'D'));
44 $end->sub(new \DateInterval('P' . 2 . 'D'));
45 }
33 46
34 47 $output->writeln("<info>Import complete!</info>"); $output->writeln("<info>Import complete!</info>");
35 48 } catch (NeoImportStructureInvalidException $e) { } catch (NeoImportStructureInvalidException $e) {
 
... ... class ImportLastThreeDaysCommand extends ContainerAwareCommand
38 51 $output->writeln("<error>Import failed: invalid url!</error>"); $output->writeln("<error>Import failed: invalid url!</error>");
39 52 } }
40 53 } }
41 }
54 }
File src/nasa/src/NeoBundle/Service/Import.php changed (mode: 100644) (index 8e62372..5aa1ebb)
... ... class Import
54 54 $this->days = $days; $this->days = $days;
55 55 } }
56 56
57 public function import()
57 public function import(\DateTime $start = null, \DateTime $end = null)
58 58 { {
59 $result = json_decode($this->buzz->get($this->getUrl())->getContent(), true);
59 if ($start === null || $end === null) {
60 $end = new \DateTime();
61 $start = new \DateTime();
62 $start->sub(new \DateInterval('P' . ($this->days - 1) . 'D'));
63 }
64
65 $result = json_decode($this->buzz->get($this->getUrl($start, $end))->getContent(), true);
60 66
61 67 if ($this->analyze($result)) { if ($this->analyze($result)) {
62 68 $this->process($result['near_earth_objects']); $this->process($result['near_earth_objects']);
 
... ... class Import
109 115 } }
110 116 } }
111 117
112 private function getUrl()
118 private function getUrl(\DateTime $start, \DateTime $end)
113 119 { {
114 $end = new \DateTime();
115 $start = new \DateTime();
116 $start->sub(new \DateInterval('P' . ($this->days - 1) . 'D'));
117
118 120 return str_replace( return str_replace(
119 121 '##key##', '##key##',
120 122 $this->key, $this->key,
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/ranapat/nasa

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/ranapat/nasa

Clone this repository using git:
git clone git://git.rocketgit.com/user/ranapat/nasa

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main