@@ -8,100 +8,100 @@ |
||
| 8 | 8 | class MysqlChangelogRepository implements ChangelogRepositoryInterface |
| 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 getChanges($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 getChanges($limit = null, $offset = 0) |
|
| 29 | + { |
|
| 30 | + $query = " |
|
| 31 | 31 | SELECT `message`, `message_short`, `datetime`, `commit_link` |
| 32 | 32 | FROM `jpemeric_stream`.`changelog` |
| 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 | - /** |
|
| 46 | - * @param string $hash |
|
| 47 | - * |
|
| 48 | - * @return array|false |
|
| 49 | - */ |
|
| 50 | - public function getChangeByHash($hash) |
|
| 51 | - { |
|
| 52 | - $query = " |
|
| 45 | + /** |
|
| 46 | + * @param string $hash |
|
| 47 | + * |
|
| 48 | + * @return array|false |
|
| 49 | + */ |
|
| 50 | + public function getChangeByHash($hash) |
|
| 51 | + { |
|
| 52 | + $query = " |
|
| 53 | 53 | SELECT * |
| 54 | 54 | FROM `jpemeric_stream`.`changelog` |
| 55 | 55 | WHERE `hash` = :hash |
| 56 | 56 | LIMIT 1"; |
| 57 | 57 | |
| 58 | - $bindings = [ |
|
| 59 | - 'hash' => $hash, |
|
| 60 | - ]; |
|
| 58 | + $bindings = [ |
|
| 59 | + 'hash' => $hash, |
|
| 60 | + ]; |
|
| 61 | 61 | |
| 62 | - return $this |
|
| 63 | - ->connections |
|
| 64 | - ->getRead() |
|
| 65 | - ->fetchOne($query, $bindings); |
|
| 66 | - } |
|
| 62 | + return $this |
|
| 63 | + ->connections |
|
| 64 | + ->getRead() |
|
| 65 | + ->fetchOne($query, $bindings); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @param string $hash |
|
| 70 | - * @param string $message |
|
| 71 | - * @param DateTime $datetime |
|
| 72 | - * @param string $author |
|
| 73 | - * @param string $commit_link |
|
| 74 | - * |
|
| 75 | - * @return |
|
| 76 | - */ |
|
| 77 | - public function insertChange($hash, $message, DateTime $datetime, $author, $commit_link) |
|
| 78 | - { |
|
| 79 | - $message_short = $message; |
|
| 80 | - $message_short = strtok($message_short, "\n"); |
|
| 81 | - if (strlen($message_short) > 72) { |
|
| 82 | - $message_short = wordwrap($message_short, 65); |
|
| 83 | - $message_short = strtok($message_short, "\n"); |
|
| 84 | - $message_short .= '...'; |
|
| 85 | - } |
|
| 68 | + /** |
|
| 69 | + * @param string $hash |
|
| 70 | + * @param string $message |
|
| 71 | + * @param DateTime $datetime |
|
| 72 | + * @param string $author |
|
| 73 | + * @param string $commit_link |
|
| 74 | + * |
|
| 75 | + * @return |
|
| 76 | + */ |
|
| 77 | + public function insertChange($hash, $message, DateTime $datetime, $author, $commit_link) |
|
| 78 | + { |
|
| 79 | + $message_short = $message; |
|
| 80 | + $message_short = strtok($message_short, "\n"); |
|
| 81 | + if (strlen($message_short) > 72) { |
|
| 82 | + $message_short = wordwrap($message_short, 65); |
|
| 83 | + $message_short = strtok($message_short, "\n"); |
|
| 84 | + $message_short .= '...'; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $query = " |
|
| 87 | + $query = " |
|
| 88 | 88 | INSERT INTO `jpemeric_stream`.`changelog` |
| 89 | 89 | (`hash`, `message`, `message_short`, `datetime`, `author`, `commit_link`) |
| 90 | 90 | VALUES |
| 91 | 91 | (:hash, :message, :message_short, :datetime, :author, :commit_link)"; |
| 92 | 92 | |
| 93 | - $bindings = [ |
|
| 94 | - 'hash' => $hash, |
|
| 95 | - 'message' => $message, |
|
| 96 | - 'message_short' => $message_short, |
|
| 97 | - 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
| 98 | - 'author' => $author, |
|
| 99 | - 'commit_link' => $commit_link |
|
| 100 | - ]; |
|
| 93 | + $bindings = [ |
|
| 94 | + 'hash' => $hash, |
|
| 95 | + 'message' => $message, |
|
| 96 | + 'message_short' => $message_short, |
|
| 97 | + 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
| 98 | + 'author' => $author, |
|
| 99 | + 'commit_link' => $commit_link |
|
| 100 | + ]; |
|
| 101 | 101 | |
| 102 | - return $this |
|
| 103 | - ->connections |
|
| 104 | - ->getWrite() |
|
| 105 | - ->perform($query, $bindings); |
|
| 106 | - } |
|
| 102 | + return $this |
|
| 103 | + ->connections |
|
| 104 | + ->getWrite() |
|
| 105 | + ->perform($query, $bindings); |
|
| 106 | + } |
|
| 107 | 107 | } |
@@ -8,89 +8,89 @@ |
||
| 8 | 8 | class MysqlGithubRepository implements GithubRepositoryInterface |
| 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 getEvents($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 getEvents($limit = null, $offset = 0) |
|
| 29 | + { |
|
| 30 | + $query = " |
|
| 31 | 31 | SELECT `id`, `event_id`, `datetime` |
| 32 | 32 | FROM `jpemeric_stream`.`github` |
| 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 | - /** |
|
| 46 | - * @param integer $eventId |
|
| 47 | - * |
|
| 48 | - * @return array|false |
|
| 49 | - */ |
|
| 50 | - public function getEventByEventId($eventId) |
|
| 51 | - { |
|
| 52 | - $query = " |
|
| 45 | + /** |
|
| 46 | + * @param integer $eventId |
|
| 47 | + * |
|
| 48 | + * @return array|false |
|
| 49 | + */ |
|
| 50 | + public function getEventByEventId($eventId) |
|
| 51 | + { |
|
| 52 | + $query = " |
|
| 53 | 53 | SELECT * |
| 54 | 54 | FROM `jpemeric_stream`.`github` |
| 55 | 55 | WHERE `event_id` = :event_id |
| 56 | 56 | LIMIT 1"; |
| 57 | 57 | |
| 58 | - $bindings = [ |
|
| 59 | - 'event_id' => $eventId, |
|
| 60 | - ]; |
|
| 58 | + $bindings = [ |
|
| 59 | + 'event_id' => $eventId, |
|
| 60 | + ]; |
|
| 61 | 61 | |
| 62 | - return $this |
|
| 63 | - ->connections |
|
| 64 | - ->getRead() |
|
| 65 | - ->fetchOne($query, $bindings); |
|
| 66 | - } |
|
| 62 | + return $this |
|
| 63 | + ->connections |
|
| 64 | + ->getRead() |
|
| 65 | + ->fetchOne($query, $bindings); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @param integer $eventId |
|
| 70 | - * @param string $eventType |
|
| 71 | - * @param DateTime $datetime |
|
| 72 | - * @param array $metadata |
|
| 73 | - * |
|
| 74 | - * @return |
|
| 75 | - */ |
|
| 76 | - public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata) |
|
| 77 | - { |
|
| 78 | - $query = " |
|
| 68 | + /** |
|
| 69 | + * @param integer $eventId |
|
| 70 | + * @param string $eventType |
|
| 71 | + * @param DateTime $datetime |
|
| 72 | + * @param array $metadata |
|
| 73 | + * |
|
| 74 | + * @return |
|
| 75 | + */ |
|
| 76 | + public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata) |
|
| 77 | + { |
|
| 78 | + $query = " |
|
| 79 | 79 | INSERT INTO `jpemeric_stream`.`github` |
| 80 | 80 | (`event_id`, `type`, `datetime`, `metadata`) |
| 81 | 81 | VALUES |
| 82 | 82 | (:event_id, :event_type, :datetime, :metadata)"; |
| 83 | 83 | |
| 84 | - $bindings = [ |
|
| 85 | - 'event_id' => $eventId, |
|
| 86 | - 'event_type' => $eventType, |
|
| 87 | - 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
| 88 | - 'metadata' => json_encode($metadata), |
|
| 89 | - ]; |
|
| 84 | + $bindings = [ |
|
| 85 | + 'event_id' => $eventId, |
|
| 86 | + 'event_type' => $eventType, |
|
| 87 | + 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
| 88 | + 'metadata' => json_encode($metadata), |
|
| 89 | + ]; |
|
| 90 | 90 | |
| 91 | - return $this |
|
| 92 | - ->connections |
|
| 93 | - ->getWrite() |
|
| 94 | - ->perform($query, $bindings); |
|
| 95 | - } |
|
| 91 | + return $this |
|
| 92 | + ->connections |
|
| 93 | + ->getWrite() |
|
| 94 | + ->perform($query, $bindings); |
|
| 95 | + } |
|
| 96 | 96 | } |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | * @return boolean |
| 17 | 17 | */ |
| 18 | 18 | $buildFeed = function (Feed $feed, $folder) { |
| 19 | - $tempFeed = __DIR__ . "/../../public/{$folder}/rss-new.xml"; |
|
| 20 | - $finalFeed = __DIR__ . "/../../public/{$folder}/rss.xml"; |
|
| 19 | + $tempFeed = __DIR__ . "/../../public/{$folder}/rss-new.xml"; |
|
| 20 | + $finalFeed = __DIR__ . "/../../public/{$folder}/rss.xml"; |
|
| 21 | 21 | |
| 22 | - $feedHandle = fopen($tempFeed, 'w'); |
|
| 23 | - fwrite($feedHandle, $feed->render()); |
|
| 24 | - fclose($feedHandle); |
|
| 22 | + $feedHandle = fopen($tempFeed, 'w'); |
|
| 23 | + fwrite($feedHandle, $feed->render()); |
|
| 24 | + fclose($feedHandle); |
|
| 25 | 25 | |
| 26 | - rename($tempFeed, $finalFeed); |
|
| 26 | + rename($tempFeed, $finalFeed); |
|
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | |
@@ -42,34 +42,34 @@ discard block |
||
| 42 | 42 | $activeBlogPosts = $blogPostRepository->getActivePosts(); |
| 43 | 43 | |
| 44 | 44 | foreach ($activeBlogPosts as $blogPost) { |
| 45 | - $blogPostItem = new Item(); |
|
| 46 | - |
|
| 47 | - $blogPostItem->title($blogPost['title']); |
|
| 48 | - |
|
| 49 | - $url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 50 | - $blogPostItem->url($url); |
|
| 51 | - $blogPostItem->guid($url, true); |
|
| 52 | - |
|
| 53 | - $description = $blogPost['body']; |
|
| 54 | - $description = strip_tags($description); |
|
| 55 | - $description = strtok($description, "\n"); |
|
| 56 | - if (strlen($description) > 250) { |
|
| 57 | - $description = wordwrap($description, 250); |
|
| 58 | - $description = strtok($description, "\n"); |
|
| 59 | - if (substr($description, -1) != '.') { |
|
| 60 | - $description .= '…'; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - $description = html_entity_decode($description); |
|
| 64 | - $blogPostItem->description($description); |
|
| 65 | - |
|
| 66 | - $categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/"; |
|
| 67 | - $blogPostItem->category($blogPost['category'], $categoryUrl); |
|
| 68 | - |
|
| 69 | - $pubDate = new DateTime($blogPost['date']); |
|
| 70 | - $blogPostItem->pubDate($pubDate->getTimestamp()); |
|
| 71 | - |
|
| 72 | - $blogPostItem->appendTo($blogPostChannel); |
|
| 45 | + $blogPostItem = new Item(); |
|
| 46 | + |
|
| 47 | + $blogPostItem->title($blogPost['title']); |
|
| 48 | + |
|
| 49 | + $url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 50 | + $blogPostItem->url($url); |
|
| 51 | + $blogPostItem->guid($url, true); |
|
| 52 | + |
|
| 53 | + $description = $blogPost['body']; |
|
| 54 | + $description = strip_tags($description); |
|
| 55 | + $description = strtok($description, "\n"); |
|
| 56 | + if (strlen($description) > 250) { |
|
| 57 | + $description = wordwrap($description, 250); |
|
| 58 | + $description = strtok($description, "\n"); |
|
| 59 | + if (substr($description, -1) != '.') { |
|
| 60 | + $description .= '…'; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + $description = html_entity_decode($description); |
|
| 64 | + $blogPostItem->description($description); |
|
| 65 | + |
|
| 66 | + $categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/"; |
|
| 67 | + $blogPostItem->category($blogPost['category'], $categoryUrl); |
|
| 68 | + |
|
| 69 | + $pubDate = new DateTime($blogPost['date']); |
|
| 70 | + $blogPostItem->pubDate($pubDate->getTimestamp()); |
|
| 71 | + |
|
| 72 | + $blogPostItem->appendTo($blogPostChannel); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $buildFeed($blogPostFeed, 'blog'); |