Completed
Push — master ( ce03f9...989695 )
by Jacob
04:19
created
src/Domain/Stream/Blog/BlogRepositoryInterface.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 interface BlogRepositoryInterface
6 6
 {
7
-    public function getBlogById($id);
8
-    public function getBlogByTitle($title);
7
+	public function getBlogById($id);
8
+	public function getBlogByTitle($title);
9 9
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Twitter/TwitterRepositoryInterface.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 interface TwitterRepositoryInterface
6 6
 {
7
-    public function getTwitterById($id);
8
-    public function getUnmappedTwitters();
7
+	public function getTwitterById($id);
8
+	public function getUnmappedTwitters();
9 9
 }
Please login to merge, or discard this patch.
controller/blog/DefaultPageController.class.inc.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 
21 21
 	protected function set_head_data()
22 22
 	{
23
-    $this->set_head('rss_link', [
24
-      'title' => 'Jacob Emerick Blog Feed',
25
-      'url' => '/rss.xml'
26
-    ]);
27
-    $this->set_head('rss_comment_link', [
28
-      'title' => 'Jacob Emerick Blog Comment Feed',
29
-      'url' => '/rss-comments.xml'
30
-    ]);
23
+	$this->set_head('rss_link', [
24
+	  'title' => 'Jacob Emerick Blog Feed',
25
+	  'url' => '/rss.xml'
26
+	]);
27
+	$this->set_head('rss_comment_link', [
28
+	  'title' => 'Jacob Emerick Blog Comment Feed',
29
+	  'url' => '/rss-comments.xml'
30
+	]);
31 31
 		
32 32
 		$this->add_css('normalize');
33 33
 		$this->add_css('blog');
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		Loader::load('collector', 'blog/TagCollector');
93 93
 		
94 94
 		$tag_result = TagCollector::getTagsForPost($post->id);
95
-        $tag_array = array();
95
+		$tag_array = array();
96 96
 		foreach($tag_result as $tag)
97 97
 		{
98 98
 			$tag_object = new stdclass();
Please login to merge, or discard this patch.
script/cron/fetch-blog-activity.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,24 +13,24 @@  discard block
 block discarded – undo
13 13
 
14 14
 $blogFeed = Feed::loadRss('http://blog.jacobemerick.com/rss.xml');
15 15
 foreach ($blogFeed->item as $item) {
16
-    $datetime = new DateTime($item->pubDate);
17
-    if ($datetime <= $mostRecentBlogDateTime) {
18
-        break;
19
-    }
20
-
21
-    $uniqueBlogCheck = $blogRepository->getBlogByPermalink((string) $item->guid);
22
-    if ($uniqueBlogCheck !== false) {
23
-        continue;
24
-    }
25
-
26
-    $datetime->setTimezone($container['default_timezone']);
27
-    $metadata = json_decode(json_encode($item), true);
28
-
29
-    $blogRepository->insertBlog(
30
-        (string) $item->guid,
31
-        $datetime,
32
-        $metadata
33
-    );
16
+	$datetime = new DateTime($item->pubDate);
17
+	if ($datetime <= $mostRecentBlogDateTime) {
18
+		break;
19
+	}
20
+
21
+	$uniqueBlogCheck = $blogRepository->getBlogByPermalink((string) $item->guid);
22
+	if ($uniqueBlogCheck !== false) {
23
+		continue;
24
+	}
25
+
26
+	$datetime->setTimezone($container['default_timezone']);
27
+	$metadata = json_decode(json_encode($item), true);
28
+
29
+	$blogRepository->insertBlog(
30
+		(string) $item->guid,
31
+		$datetime,
32
+		$metadata
33
+	);
34 34
 }
35 35
 
36 36
 $blogCommentRepository = new BlogCommentRepository($container['db_connection_locator']);
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
 
42 42
 $commentFeed = Feed::loadRss('http://blog.jacobemerick.com/rss-comments.xml');
43 43
 foreach ($commentFeed->item as $item) {
44
-    $datetime = new DateTime($item->pubDate);
45
-    if ($datetime <= $mostRecentBlogCommentDateTime) {
46
-        break;
47
-    }
48
-
49
-    $uniqueBlogCommentCheck = $blogCommentRepository->getBlogCommentByPermalink((string) $item->guid);
50
-    if ($uniqueBlogCommentCheck !== false) {
51
-        continue;
52
-    }
53
-
54
-    $datetime->setTimezone($container['default_timezone']);
55
-    $metadata = json_decode(json_encode($item), true);
56
-
57
-    $blogCommentRepository->insertBlogComment(
58
-        (string) $item->guid,
59
-        $datetime,
60
-        $metadata
61
-    );
44
+	$datetime = new DateTime($item->pubDate);
45
+	if ($datetime <= $mostRecentBlogCommentDateTime) {
46
+		break;
47
+	}
48
+
49
+	$uniqueBlogCommentCheck = $blogCommentRepository->getBlogCommentByPermalink((string) $item->guid);
50
+	if ($uniqueBlogCommentCheck !== false) {
51
+		continue;
52
+	}
53
+
54
+	$datetime->setTimezone($container['default_timezone']);
55
+	$metadata = json_decode(json_encode($item), true);
56
+
57
+	$blogCommentRepository->insertBlogComment(
58
+		(string) $item->guid,
59
+		$datetime,
60
+		$metadata
61
+	);
62 62
 }
Please login to merge, or discard this patch.
script/cron/fetch-goodreads-activity.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use Jacobemerick\Web\Domain\Stream\Goodread\MysqlGoodreadRepository as GoodreadRepository;
7 7
 
8 8
 $client = new Client([
9
-    'base_uri' => 'http://www.goodreads.com',
9
+	'base_uri' => 'http://www.goodreads.com',
10 10
 ]);
11 11
 
12 12
 $goodreadRepository = new GoodreadRepository($container['db_connection_locator']);
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
 $reviews = simplexml_load_string($reviews, 'SimpleXMLElement', LIBXML_NOCDATA);
21 21
 
22 22
 foreach ($reviews->channel->item as $review) {
23
-    $datetime = new DateTime((string) $review->pubDate);
24
-    if ($datetime <= $mostRecentReviewDateTime) {
25
-        break;
26
-    }
27
-
28
-    $uniqueReviewCheck = $goodreadRepository->getReviewByPermalink((string) $review->guid);
29
-    if ($uniqueReviewCheck !== false) {
30
-        continue;
31
-    }
32
-
33
-    $datetime->setTimezone($container['default_timezone']);
34
-    $metadata = json_decode(json_encode($review), true);
35
-
36
-    $goodreadRepository->insertReview(
37
-        (string) $review->guid,
38
-        (string) $review->book_id,
39
-        $datetime,
40
-        $metadata
41
-    );
23
+	$datetime = new DateTime((string) $review->pubDate);
24
+	if ($datetime <= $mostRecentReviewDateTime) {
25
+		break;
26
+	}
27
+
28
+	$uniqueReviewCheck = $goodreadRepository->getReviewByPermalink((string) $review->guid);
29
+	if ($uniqueReviewCheck !== false) {
30
+		continue;
31
+	}
32
+
33
+	$datetime->setTimezone($container['default_timezone']);
34
+	$metadata = json_decode(json_encode($review), true);
35
+
36
+	$goodreadRepository->insertReview(
37
+		(string) $review->guid,
38
+		(string) $review->book_id,
39
+		$datetime,
40
+		$metadata
41
+	);
42 42
 }
Please login to merge, or discard this patch.
script/manual/historic-twitter-fetch.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
 
5 5
 $options = getopt('f:');
6 6
 if (empty($options['f'])) {
7
-    exit('Must pass in a file with the f parameter.');
7
+	exit('Must pass in a file with the f parameter.');
8 8
 }
9 9
 
10 10
 use Abraham\TwitterOAuth\TwitterOAuth;
11 11
 use Jacobemerick\Web\Domain\Stream\Twitter\MysqlTwitterRepository as TwitterRepository;
12 12
 
13 13
 $client = new TwitterOAuth(
14
-    $config->twitter->consumer_key,
15
-    $config->twitter->consumer_secret,
16
-    $config->twitter->access_token,
17
-    $config->twitter->access_token_secret
14
+	$config->twitter->consumer_key,
15
+	$config->twitter->consumer_secret,
16
+	$config->twitter->access_token,
17
+	$config->twitter->access_token_secret
18 18
 );
19 19
 $client->setDecodeJsonAsArray(true);
20 20
 
@@ -24,29 +24,29 @@  discard block
 block discarded – undo
24 24
 
25 25
 $handle = fopen(__DIR__ . '/' . $options['f'], 'r');
26 26
 while ($row = fgets($handle)) {
27
-    array_push($idList, trim($row));
28
-    if (count($idList) == 100) {
29
-        $tweetLookup = $client->get('statuses/lookup', [
30
-            'id' => implode(',', $idList),
31
-            'trim_user' => true,
32
-        ]);
33
-
34
-        foreach ($tweetLookup as $tweet) {
35
-            $uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']);
36
-            if ($uniqueTweetCheck !== false) {
37
-                if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) {
38
-                    $twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet);
39
-                }
40
-                continue;
41
-            }
42
-
43
-            $twitterRepository->insertTweet(
44
-                $tweet['id_str'],
45
-                (new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']),
46
-                $tweet
47
-            );
48
-        }
49
-        $idList = [];
50
-    }
27
+	array_push($idList, trim($row));
28
+	if (count($idList) == 100) {
29
+		$tweetLookup = $client->get('statuses/lookup', [
30
+			'id' => implode(',', $idList),
31
+			'trim_user' => true,
32
+		]);
33
+
34
+		foreach ($tweetLookup as $tweet) {
35
+			$uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']);
36
+			if ($uniqueTweetCheck !== false) {
37
+				if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) {
38
+					$twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet);
39
+				}
40
+				continue;
41
+			}
42
+
43
+			$twitterRepository->insertTweet(
44
+				$tweet['id_str'],
45
+				(new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']),
46
+				$tweet
47
+			);
48
+		}
49
+		$idList = [];
50
+	}
51 51
 }
52 52
 fclose($handle);
Please login to merge, or discard this patch.
src/Domain/Stream/Goodread/MysqlGoodreadRepository.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -8,76 +8,76 @@
 block discarded – undo
8 8
 class MysqlGoodreadRepository implements GoodreadRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13 13
 
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21 21
 
22
-    /**
23
-     * @param integer $limit
24
-     * @param integer $offset
25
-     *
26
-     * @return array|false
27
-     */
28
-    public function getReviews($limit = null, $offset = 0)
29
-    {
30
-        $query = "
22
+	/**
23
+	 * @param integer $limit
24
+	 * @param integer $offset
25
+	 *
26
+	 * @return array|false
27
+	 */
28
+	public function getReviews($limit = null, $offset = 0)
29
+	{
30
+		$query = "
31 31
             SELECT `id`, `permalink`, `datetime`
32 32
             FROM `jpemeric_stream`.`goodread`
33 33
             ORDER BY `datetime` DESC";
34
-        if (!is_null($limit)) {
35
-          $query .= "
34
+		if (!is_null($limit)) {
35
+		  $query .= "
36 36
           LIMIT {$offset}, {$limit}";
37
-        }
37
+		}
38 38
 
39
-        return $this
40
-            ->connections
41
-            ->getRead()
42
-            ->fetchAll($query);
43
-    }
39
+		return $this
40
+			->connections
41
+			->getRead()
42
+			->fetchAll($query);
43
+	}
44 44
 
45
-    public function getReviewByPermalink($permalink)
46
-    {
47
-        $query = "
45
+	public function getReviewByPermalink($permalink)
46
+	{
47
+		$query = "
48 48
             SELECT *
49 49
             FROM `jpemeric_stream`.`goodread`
50 50
             WHERE `permalink` = :permalink
51 51
             LIMIT 1";
52 52
 
53
-        $bindings = [
54
-            'permalink' => $permalink,
55
-        ];
53
+		$bindings = [
54
+			'permalink' => $permalink,
55
+		];
56 56
 
57
-        return $this
58
-            ->connections
59
-            ->getRead()
60
-            ->fetchOne($query, $bindings);
61
-    }
57
+		return $this
58
+			->connections
59
+			->getRead()
60
+			->fetchOne($query, $bindings);
61
+	}
62 62
 
63
-    public function insertReview($permalink, $bookId, DateTime $datetime, array $metadata)
64
-    {
65
-        $query = "
63
+	public function insertReview($permalink, $bookId, DateTime $datetime, array $metadata)
64
+	{
65
+		$query = "
66 66
             INSERT INTO `jpemeric_stream`.`goodread`
67 67
                 (`permalink`, `book_id`, `datetime`, `metadata`)
68 68
             VALUES
69 69
                 (:permalink, :book_id, :datetime, :metadata)";
70 70
 
71
-        $bindings = [
72
-            'permalink' => $permalink,
73
-            'book_id' => $bookId,
74
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
75
-            'metadata' => json_encode($metadata),
76
-        ];
71
+		$bindings = [
72
+			'permalink' => $permalink,
73
+			'book_id' => $bookId,
74
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
75
+			'metadata' => json_encode($metadata),
76
+		];
77 77
 
78
-        return $this
79
-            ->connections
80
-            ->getWrite()
81
-            ->perform($query, $bindings);
82
-    }
78
+		return $this
79
+			->connections
80
+			->getWrite()
81
+			->perform($query, $bindings);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
script/cron/build-activity-stream.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
 
12 12
 $lastBlogActivity = $activityRepository->getActivityLastUpdateByType('blog');
13 13
 if ($lastBlogActivity === false) {
14
-    $lastBlogActivityDateTime = new DateTime('2008-05-03');
14
+	$lastBlogActivityDateTime = new DateTime('2008-05-03');
15 15
 } else {
16
-    $lastBlogActivityDateTime = new DateTime($lastBlogActivity['updated_at']);
17
-    $lastBlogActivityDateTime->modify('-5 days');
16
+	$lastBlogActivityDateTime = new DateTime($lastBlogActivity['updated_at']);
17
+	$lastBlogActivityDateTime->modify('-5 days');
18 18
 }
19 19
 $newBlogActivity = $blogRepository->getBlogsUpdatedSince($lastBlogActivityDateTime);
20 20
 foreach ($newBlogActivity as $blog) {
21
-    $uniqueBlogCheck = $activityRepository->getActivityByTypeId('blog', $blog['id']);
22
-    if ($uniqueBlogCheck !== false) {
23
-        continue;
24
-    }
21
+	$uniqueBlogCheck = $activityRepository->getActivityByTypeId('blog', $blog['id']);
22
+	if ($uniqueBlogCheck !== false) {
23
+		continue;
24
+	}
25 25
 
26
-    $blogData = json_decode($blog['metadata'], true);
27
-    $message = sprintf(
28
-        'Blogged about %s: <a href="%s" title="Jacob Emerick\'s Blog | %s">%s</a>.',
29
-        str_replace('-', ' ', $blogData['category']),
30
-        $blogData['link'],
31
-        $blogData['title'],
32
-        $blogData['title']
33
-    );
34
-    $messageLong = sprintf(
35
-        "<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
36
-        "<p>%s [<a href=\"%s\">read more</a></a>]</p>",
37
-        $blogData['link'],
38
-        $blogData['title'],
39
-        $blogData['title'],
40
-        htmlentities($blogData['description']),
41
-        $blogData['link']
42
-    );
26
+	$blogData = json_decode($blog['metadata'], true);
27
+	$message = sprintf(
28
+		'Blogged about %s: <a href="%s" title="Jacob Emerick\'s Blog | %s">%s</a>.',
29
+		str_replace('-', ' ', $blogData['category']),
30
+		$blogData['link'],
31
+		$blogData['title'],
32
+		$blogData['title']
33
+	);
34
+	$messageLong = sprintf(
35
+		"<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
36
+		"<p>%s [<a href=\"%s\">read more</a></a>]</p>",
37
+		$blogData['link'],
38
+		$blogData['title'],
39
+		$blogData['title'],
40
+		htmlentities($blogData['description']),
41
+		$blogData['link']
42
+	);
43 43
 
44
-    $activityRepository->insertActivity(
45
-        $message,
46
-        $messageLong,
47
-        (new DateTime($blog['datetime'])),
48
-        [],
49
-        'blog',
50
-        $blog['id']
51
-    );
44
+	$activityRepository->insertActivity(
45
+		$message,
46
+		$messageLong,
47
+		(new DateTime($blog['datetime'])),
48
+		[],
49
+		'blog',
50
+		$blog['id']
51
+	);
52 52
 }
53 53
 
54 54
 use Jacobemerick\Web\Domain\Stream\BlogComment\MysqlBlogCommentRepository as BlogCommentRepository;
@@ -56,28 +56,28 @@  discard block
 block discarded – undo
56 56
 $blogCommentActivity = $blogCommentRepository->getBlogComments();
57 57
 $blogCommentHolder = [];
58 58
 foreach ($blogCommentActivity as $blogComment) {
59
-    $blogPermalink = $blogComment['permalink'];
60
-    $blogPermalink = explode('#', $blogPermalink);
61
-    $blogPermalink = current($blogPermalink);
59
+	$blogPermalink = $blogComment['permalink'];
60
+	$blogPermalink = explode('#', $blogPermalink);
61
+	$blogPermalink = current($blogPermalink);
62 62
 
63
-    $blog = $blogRepository->getBlogByPermalink($blogPermalink);
64
-    if (!array_key_exists($blog['id'], $blogCommentHolder)) {
65
-        $blogCommentHolder[$blog['id']] = 1;
66
-    } else {
67
-        $blogCommentHolder[$blog['id']]++;
68
-    }
63
+	$blog = $blogRepository->getBlogByPermalink($blogPermalink);
64
+	if (!array_key_exists($blog['id'], $blogCommentHolder)) {
65
+		$blogCommentHolder[$blog['id']] = 1;
66
+	} else {
67
+		$blogCommentHolder[$blog['id']]++;
68
+	}
69 69
 }
70 70
 
71 71
 foreach ($blogCommentHolder as $blogId => $commentCount) {
72
-    $blogActivity = $activityRepository->getActivityByTypeId('blog', $blogId);
73
-    $blogActivityMetadata = json_decode($blogActivity['metadata']);
74
-    if (
75
-        !isset($blogActivityMetadata['comments']) ||
76
-        $blogActivityMetadata['comments'] != $commentCount
77
-    ) {
78
-        $activityRepository->updateActivityMetadata(
79
-            $blogActivity['id'],
80
-            ['comments' => $commentCount]
81
-        );
82
-    }
72
+	$blogActivity = $activityRepository->getActivityByTypeId('blog', $blogId);
73
+	$blogActivityMetadata = json_decode($blogActivity['metadata']);
74
+	if (
75
+		!isset($blogActivityMetadata['comments']) ||
76
+		$blogActivityMetadata['comments'] != $commentCount
77
+	) {
78
+		$activityRepository->updateActivityMetadata(
79
+			$blogActivity['id'],
80
+			['comments' => $commentCount]
81
+		);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Activity/ActivityRepositoryInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@
 block discarded – undo
4 4
 
5 5
 interface ActivityRepositoryInterface
6 6
 {
7
-    public function getActivityById($id);
8
-    public function getActivities($limit = null, $offset = 0);
9
-    public function getActivitiesCount();
10
-    public function getActivitiesByType($type, $limit = null, $offset = 0);
11
-    public function getActivitiesByTypeCount($type);
7
+	public function getActivityById($id);
8
+	public function getActivities($limit = null, $offset = 0);
9
+	public function getActivitiesCount();
10
+	public function getActivitiesByType($type, $limit = null, $offset = 0);
11
+	public function getActivitiesByTypeCount($type);
12 12
 }
Please login to merge, or discard this patch.