Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

2294 - 3 #276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

2294 - 3 #276

wants to merge 2 commits into from

Conversation

DenisVolchek
Copy link
Contributor

@DenisVolchek DenisVolchek commented Jul 27, 2018

Номер

2294

Номер задания

3

Ссылка на видео с демо

Комментарии

Реализован пул комментариев с сайта.
Комментарии сортируются по количеству лайков, и используется 50 лучших.
Набросана верстка с использование bootstrap3.0
Подключен azure.
Не реализиновано :

  • работа с бд ( подключены), но не используются
  • все связать.

Не успеваю доделать в срок из-за отъезда в другой город.

2294/3/Gemfile Outdated
gem 'shotgun'
gem 'thin'
gem 'sinatra'
gem 'ohm'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem ohm should appear before sinatra.

2294/3/Gemfile Outdated
gem 'pry'
gem 'shotgun'
gem 'thin'
gem 'sinatra'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem sinatra should appear before thin.

class ApplicationController < Sinatra::Base
set :views, File.expand_path(File.join(__FILE__, '../../views'))
set :public_folder, File.expand_path(File.join(__FILE__, '../../assets'))
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

class Comment < Ohm::Model
attribute :message
attribute :rating
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

attribute :link
attribute :rating
set :comments, :Comment
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

end

def form_hash
data = {'documents' => []}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.

end

# Forms azure body for request
class AzureHash

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

def create
Article.create(link: @link, rating: 0)
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

ArticleCreator.new(@link).create
redirect '/'
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

not_found do
status 404
erb :not_found
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/BlockAlignment: end at 12, 4 is not aligned with not_found do at 9, 2.

end
end

ACCESS_KEY = '84696ed14a214431b4e25945879458e2'.freeze
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Dotenv or Figaro

end

def create_hash_of_comments
@array_of_objects.each { |obj| @pack << obj.message }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the common pattern for such cases is

def pack
  @pack ||= @array_of_objects.map(&:message)
end

LIMIT = 50
def initialize
@comments = JSONParser.new.comments_options
@array = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

private

def array_of_objects
@comments.each do |variable|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@array = @comments.map do ...

# Take messages from sorted by onliner's rating array
class PackCreator
def initialize
@array_of_objects = Analyze.new.sort_array_of_objects
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't u want to pass these objects as new argument?
And give it more meaningful name


def form_hash
data = { 'documents' => [] }
@pack.each_with_index do |comment, index|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.map + .with_index


documents = AzureHash.new.form_hash

puts 'Please wait a moment for the results to appear.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puts in webapp?

# p JSON.parse(response.body)

JSON.parse(response.body).each do |variable|
p variable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf is going on here?

class Analyze
LIMIT = 50
def initialize
@comments = JSONParser.new.comments_options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass as argument

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants