-
Notifications
You must be signed in to change notification settings - Fork 43
2294 - 3 #276
base: master
Are you sure you want to change the base?
2294 - 3 #276
Conversation
2294/3/Gemfile
Outdated
gem 'shotgun' | ||
gem 'thin' | ||
gem 'sinatra' | ||
gem 'ohm' |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
2294/3/helpers/azure.rb
Outdated
end | ||
|
||
def form_hash | ||
data = {'documents' => []} |
There was a problem hiding this comment.
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.
2294/3/helpers/azure.rb
Outdated
end | ||
|
||
# Forms azure body for request | ||
class AzureHash |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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 = [] |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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.' |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass as argument
Номер
2294
Номер задания
3
Ссылка на видео с демо
Комментарии
Реализован пул комментариев с сайта.
Комментарии сортируются по количеству лайков, и используется 50 лучших.
Набросана верстка с использование bootstrap3.0
Подключен azure.
Не реализиновано :
Не успеваю доделать в срок из-за отъезда в другой город.