Skip to content
Snippets Groups Projects
Unverified Commit 78cb46e5 authored by Robb Lewis's avatar Robb Lewis
Browse files

Move and rename

parent c7e97541
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,14 +2,12 @@
 
namespace App\Console\Commands;
 
use App\FetchLog;
use App\Formatter;
use App\Fetcher\FetchLog;
use App\Tweets\Formatter;
use App\Tweets\Api;
use App\Tweets\Tweet;
use App\Tweets\TweetRepository;
use App\User;
use Illuminate\Console\Command;
use Thujohn\Twitter\Facades\Twitter;
 
class Fetch extends Command
{
Loading
Loading
@@ -119,11 +117,7 @@ class Fetch extends Command
// Ascending sort, oldest first
$tweets = array_reverse($tweets);
 
foreach ($tweets as $tweet) {
$this->info('Importing tweet ' . $tweet['tweetid']);
$this->tweets->create($tweet);
}
$this->tweets->addTweets($tweets);
 
$this->log($tweetCount);
}
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
namespace App\Console\Commands;
 
use App\Archive\LogRepository;
use App\Formatter;
use App\Tweets\Formatter;
use App\Tweets\TweetRepository;
use Illuminate\Console\Command;
 
Loading
Loading
@@ -92,9 +92,7 @@ class Import extends Command
// Ascending sort, oldest first
$tweets = array_reverse($tweets);
 
foreach($tweets as $tweet) {
$this->tweets->create($tweet);
}
$this->tweets->addTweets($tweets);
}
 
$tweets = [];
Loading
Loading
<?php
 
namespace App;
namespace App\Fetcher;
 
use Illuminate\Database\Eloquent\Model;
 
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
namespace App\Http\Controllers;
 
use App\FetchLog;
use App\Fetcher\FetchLog;
 
class LogController extends Controller
{
Loading
Loading
<?php
 
namespace App;
namespace App\Tweets;
 
class Formatter {
 
Loading
Loading
Loading
Loading
@@ -67,11 +67,23 @@ class TweetRepository {
* @param $tweet
* @return Tweet
*/
public function create($tweet)
public function addTweet($tweet)
{
return Tweet::firstOrCreate($tweet);
}
 
/**
* Add tweets to DB
*
* @param array $tweets
*/
public function addTweets(array $tweets)
{
foreach ($tweets as $tweet) {
$this->addTweet($tweet);
}
}
/**
* Search tweets
*
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment