protected function fire(InputInterface $input, OutputInterface $output) { $usernames = $input->getArgument('usernames'); $api = new Api(); foreach ($usernames as $username) { $followers = $api->followersIds($username); $followings = $api->followingsIds($username); $this->db->relationships->insert(array('username' => $username, 'time' => new MongoDate(), 'followers' => $followers, 'followings' => $followings)); if (!$output->isQuiet()) { $this->info(sprintf("Synced %s:\t Following %s\t Followers %s", $username, count($followings), count($followers))); } } }
protected function fire(InputInterface $input, OutputInterface $output) { $usernames = $input->getArgument('usernames'); $api = new Api(); $merged = []; foreach ($usernames as $username) { $followers = $api->followersIds($username); dump('data/followers-' . $username . '.json', $followers); foreach ($followers as $f) { $merged[] = [$f, $username]; } } $tmpFilename = sprintf('merged-%s', date('Ymd-His')); dump('data/' . $tmpFilename, $merged); $md5 = md5_file(app_path('data/' . $tmpFilename)); rename(app_path('data/' . $tmpFilename), app_path('data/' . $tmpFilename . '-' . $md5 . '.json')); }