{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/comments/243913354","pull_request_review_id":187795687,"id":243913354,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MzkxMzM1NA==","diff_hunk":"@@ -0,0 +1,95 @@\n+import { IMeasurement } from '../state/weather/types';\n+import { IArticle } from '../state/news/types';\n+import { IObservable, IObserver } from '../utils/observable/types';\n+import { IView } from './types';\n+import { NewsState } from '../state/news';\n+import { WeatherState } from '../state/weather';\n+\n+export class View implements IObserver, IView {\n+    private lastMeasurements: IMeasurement[] = [];\n+    private lastArticles: IArticle[] = [];\n+    private readonly lastMeasurementsCount: number;\n+    private readonly lastArticlesCount: number;\n+    private readonly name: string;\n+\n+    public constructor(lastArticlesCount: number, lastMeasurementsCount: number, name: string) {\n+        this.lastArticlesCount = lastArticlesCount;\n+        this.lastMeasurementsCount = lastMeasurementsCount;\n+        this.name = name;\n+    }\n+\n+    public render(): void {\n+        console.log(`<div class=\"${this.name}\">\\n${this.getRenderedString()}\\n</div>`);\n+    }\n+\n+    public update(observable: IObservable): void {\n+        if (observable instanceof NewsState) {\n+            const isUpdated = this.setLastArticles(observable.getArticles());\n+            if (isUpdated) {\n+                this.render();\n+            }\n+        }\n+\n+        if (observable instanceof WeatherState) {\n+            const isUpdated = this.setLastMeasurements(observable.getMeasurements());\n+            if (isUpdated) {\n+                this.render();\n+            }\n+        }\n+    }\n+\n+    protected getRenderedString() {\n+        const measurementsString = this.lastMeasurements\n+            .map(measurement => this.getStringMeasurement(measurement))\n+            .join('\\n');\n+        const articlesString = this.lastArticles\n+            .map(article => this.getStringArticle(article))\n+            .join('\\n');\n+\n+        return [articlesString, measurementsString].filter(str => str.length > 0).join('\\n');\n+    }\n+\n+    protected setLastMeasurements(measurements: IMeasurement[]): boolean {\n+        const newMeasurements = measurements.slice(\n+            Math.max(measurements.length - this.lastMeasurementsCount, 0),","path":"src/views/view.ts","position":54,"original_position":54,"commit_id":"f23a83c77fcfd110eac1b7bba17fe56955175726","original_commit_id":"f23a83c77fcfd110eac1b7bba17fe56955175726","user":{"login":"SemyonMakhaev","id":18099714,"node_id":"MDQ6VXNlcjE4MDk5NzE0","avatar_url":"https://avatars1.githubusercontent.com/u/18099714?v=4","gravatar_id":"","url":"https://api.github.com/users/SemyonMakhaev","html_url":"https://github.com/SemyonMakhaev","followers_url":"https://api.github.com/users/SemyonMakhaev/followers","following_url":"https://api.github.com/users/SemyonMakhaev/following{/other_user}","gists_url":"https://api.github.com/users/SemyonMakhaev/gists{/gist_id}","starred_url":"https://api.github.com/users/SemyonMakhaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SemyonMakhaev/subscriptions","organizations_url":"https://api.github.com/users/SemyonMakhaev/orgs","repos_url":"https://api.github.com/users/SemyonMakhaev/repos","events_url":"https://api.github.com/users/SemyonMakhaev/events{/privacy}","received_events_url":"https://api.github.com/users/SemyonMakhaev/received_events","type":"User","site_admin":false},"body":"Давай эту конструкцию вынесем в переменную, чтобы код был более читаемым?","created_at":"2018-12-25T14:46:37Z","updated_at":"2018-12-25T14:54:01Z","html_url":"https://github.com/urfu-2018/typescript-task-1/pull/52#discussion_r243913354","pull_request_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/comments/243913354"},"html":{"href":"https://github.com/urfu-2018/typescript-task-1/pull/52#discussion_r243913354"},"pull_request":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52","id":240865408,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQwODY1NDA4","html_url":"https://github.com/urfu-2018/typescript-task-1/pull/52","diff_url":"https://github.com/urfu-2018/typescript-task-1/pull/52.diff","patch_url":"https://github.com/urfu-2018/typescript-task-1/pull/52.patch","issue_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/52","number":52,"state":"open","locked":false,"title":"Копылов Дмитрий","user":{"login":"Dm17r1y","id":32416034,"node_id":"MDQ6VXNlcjMyNDE2MDM0","avatar_url":"https://avatars1.githubusercontent.com/u/32416034?v=4","gravatar_id":"","url":"https://api.github.com/users/Dm17r1y","html_url":"https://github.com/Dm17r1y","followers_url":"https://api.github.com/users/Dm17r1y/followers","following_url":"https://api.github.com/users/Dm17r1y/following{/other_user}","gists_url":"https://api.github.com/users/Dm17r1y/gists{/gist_id}","starred_url":"https://api.github.com/users/Dm17r1y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dm17r1y/subscriptions","organizations_url":"https://api.github.com/users/Dm17r1y/orgs","repos_url":"https://api.github.com/users/Dm17r1y/repos","events_url":"https://api.github.com/users/Dm17r1y/events{/privacy}","received_events_url":"https://api.github.com/users/Dm17r1y/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-25T11:20:51Z","updated_at":"2018-12-25T14:54:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"235faf22e03170e38b42053f21d7a700243e8a15","assignee":{"login":"SemyonMakhaev","id":18099714,"node_id":"MDQ6VXNlcjE4MDk5NzE0","avatar_url":"https://avatars1.githubusercontent.com/u/18099714?v=4","gravatar_id":"","url":"https://api.github.com/users/SemyonMakhaev","html_url":"https://github.com/SemyonMakhaev","followers_url":"https://api.github.com/users/SemyonMakhaev/followers","following_url":"https://api.github.com/users/SemyonMakhaev/following{/other_user}","gists_url":"https://api.github.com/users/SemyonMakhaev/gists{/gist_id}","starred_url":"https://api.github.com/users/SemyonMakhaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SemyonMakhaev/subscriptions","organizations_url":"https://api.github.com/users/SemyonMakhaev/orgs","repos_url":"https://api.github.com/users/SemyonMakhaev/repos","events_url":"https://api.github.com/users/SemyonMakhaev/events{/privacy}","received_events_url":"https://api.github.com/users/SemyonMakhaev/received_events","type":"User","site_admin":false},"assignees":[{"login":"SemyonMakhaev","id":18099714,"node_id":"MDQ6VXNlcjE4MDk5NzE0","avatar_url":"https://avatars1.githubusercontent.com/u/18099714?v=4","gravatar_id":"","url":"https://api.github.com/users/SemyonMakhaev","html_url":"https://github.com/SemyonMakhaev","followers_url":"https://api.github.com/users/SemyonMakhaev/followers","following_url":"https://api.github.com/users/SemyonMakhaev/following{/other_user}","gists_url":"https://api.github.com/users/SemyonMakhaev/gists{/gist_id}","starred_url":"https://api.github.com/users/SemyonMakhaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SemyonMakhaev/subscriptions","organizations_url":"https://api.github.com/users/SemyonMakhaev/orgs","repos_url":"https://api.github.com/users/SemyonMakhaev/repos","events_url":"https://api.github.com/users/SemyonMakhaev/events{/privacy}","received_events_url":"https://api.github.com/users/SemyonMakhaev/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52/commits","review_comments_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52/comments","review_comment_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/52/comments","statuses_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/statuses/f23a83c77fcfd110eac1b7bba17fe56955175726","head":{"label":"Dm17r1y:master","ref":"master","sha":"f23a83c77fcfd110eac1b7bba17fe56955175726","user":{"login":"Dm17r1y","id":32416034,"node_id":"MDQ6VXNlcjMyNDE2MDM0","avatar_url":"https://avatars1.githubusercontent.com/u/32416034?v=4","gravatar_id":"","url":"https://api.github.com/users/Dm17r1y","html_url":"https://github.com/Dm17r1y","followers_url":"https://api.github.com/users/Dm17r1y/followers","following_url":"https://api.github.com/users/Dm17r1y/following{/other_user}","gists_url":"https://api.github.com/users/Dm17r1y/gists{/gist_id}","starred_url":"https://api.github.com/users/Dm17r1y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dm17r1y/subscriptions","organizations_url":"https://api.github.com/users/Dm17r1y/orgs","repos_url":"https://api.github.com/users/Dm17r1y/repos","events_url":"https://api.github.com/users/Dm17r1y/events{/privacy}","received_events_url":"https://api.github.com/users/Dm17r1y/received_events","type":"User","site_admin":false},"repo":{"id":163072586,"node_id":"MDEwOlJlcG9zaXRvcnkxNjMwNzI1ODY=","name":"typescript-task-1","full_name":"Dm17r1y/typescript-task-1","private":false,"owner":{"login":"Dm17r1y","id":32416034,"node_id":"MDQ6VXNlcjMyNDE2MDM0","avatar_url":"https://avatars1.githubusercontent.com/u/32416034?v=4","gravatar_id":"","url":"https://api.github.com/users/Dm17r1y","html_url":"https://github.com/Dm17r1y","followers_url":"https://api.github.com/users/Dm17r1y/followers","following_url":"https://api.github.com/users/Dm17r1y/following{/other_user}","gists_url":"https://api.github.com/users/Dm17r1y/gists{/gist_id}","starred_url":"https://api.github.com/users/Dm17r1y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dm17r1y/subscriptions","organizations_url":"https://api.github.com/users/Dm17r1y/orgs","repos_url":"https://api.github.com/users/Dm17r1y/repos","events_url":"https://api.github.com/users/Dm17r1y/events{/privacy}","received_events_url":"https://api.github.com/users/Dm17r1y/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Dm17r1y/typescript-task-1","description":"Задача «Приключения Аркадия в Тайплэнде»","fork":true,"url":"https://api.github.com/repos/Dm17r1y/typescript-task-1","forks_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/forks","keys_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/teams","hooks_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/hooks","issue_events_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/issues/events{/number}","events_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/events","assignees_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/assignees{/user}","branches_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/branches{/branch}","tags_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/tags","blobs_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/statuses/{sha}","languages_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/languages","stargazers_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/stargazers","contributors_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/contributors","subscribers_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/subscribers","subscription_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/subscription","commits_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/contents/{+path}","compare_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/merges","archive_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/downloads","issues_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/issues{/number}","pulls_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/pulls{/number}","milestones_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/milestones{/number}","notifications_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/labels{/name}","releases_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/releases{/id}","deployments_url":"https://api.github.com/repos/Dm17r1y/typescript-task-1/deployments","created_at":"2018-12-25T10:25:29Z","updated_at":"2018-12-25T12:35:03Z","pushed_at":"2018-12-25T12:35:01Z","git_url":"git://github.com/Dm17r1y/typescript-task-1.git","ssh_url":"git@github.com:Dm17r1y/typescript-task-1.git","clone_url":"https://github.com/Dm17r1y/typescript-task-1.git","svn_url":"https://github.com/Dm17r1y/typescript-task-1","homepage":"","size":29,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urfu-2018:master","ref":"master","sha":"096d7982bcf0665571f83e6ed6038d54ef6c10cb","user":{"login":"urfu-2018","id":43127233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMTI3MjMz","avatar_url":"https://avatars0.githubusercontent.com/u/43127233?v=4","gravatar_id":"","url":"https://api.github.com/users/urfu-2018","html_url":"https://github.com/urfu-2018","followers_url":"https://api.github.com/users/urfu-2018/followers","following_url":"https://api.github.com/users/urfu-2018/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2018/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2018/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2018/subscriptions","organizations_url":"https://api.github.com/users/urfu-2018/orgs","repos_url":"https://api.github.com/users/urfu-2018/repos","events_url":"https://api.github.com/users/urfu-2018/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2018/received_events","type":"Organization","site_admin":false},"repo":{"id":161788132,"node_id":"MDEwOlJlcG9zaXRvcnkxNjE3ODgxMzI=","name":"typescript-task-1","full_name":"urfu-2018/typescript-task-1","private":false,"owner":{"login":"urfu-2018","id":43127233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMTI3MjMz","avatar_url":"https://avatars0.githubusercontent.com/u/43127233?v=4","gravatar_id":"","url":"https://api.github.com/users/urfu-2018","html_url":"https://github.com/urfu-2018","followers_url":"https://api.github.com/users/urfu-2018/followers","following_url":"https://api.github.com/users/urfu-2018/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2018/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2018/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2018/subscriptions","organizations_url":"https://api.github.com/users/urfu-2018/orgs","repos_url":"https://api.github.com/users/urfu-2018/repos","events_url":"https://api.github.com/users/urfu-2018/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2018/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/urfu-2018/typescript-task-1","description":"Задача «Приключения Аркадия в Тайплэнде»","fork":false,"url":"https://api.github.com/repos/urfu-2018/typescript-task-1","forks_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/forks","keys_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/teams","hooks_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/hooks","issue_events_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/events","assignees_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/tags","blobs_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/languages","stargazers_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/stargazers","contributors_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/contributors","subscribers_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/subscribers","subscription_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/subscription","commits_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/merges","archive_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/downloads","issues_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2018/typescript-task-1/deployments","created_at":"2018-12-14T13:27:29Z","updated_at":"2018-12-14T13:58:08Z","pushed_at":"2018-12-25T12:35:03Z","git_url":"git://github.com/urfu-2018/typescript-task-1.git","ssh_url":"git@github.com:urfu-2018/typescript-task-1.git","clone_url":"https://github.com/urfu-2018/typescript-task-1.git","svn_url":"https://github.com/urfu-2018/typescript-task-1","homepage":"","size":19,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":64,"mirror_url":null,"archived":false,"open_issues_count":31,"license":null,"forks":64,"open_issues":31,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52"},"html":{"href":"https://github.com/urfu-2018/typescript-task-1/pull/52"},"issue":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/52"},"comments":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2018/typescript-task-1/statuses/f23a83c77fcfd110eac1b7bba17fe56955175726"}},"author_association":"NONE"}}
{"actor":{"display_login":"SemyonMakhaev"}}