-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag autocompleters #96
Conversation
config/routes.rb
Outdated
@@ -4,8 +4,11 @@ | |||
resources :identifiers, only: [:show] | |||
resources :users, only: [:show, :index, :create, :update] do | |||
resource :user_deposit, only: [:create], path: 'deposit' | |||
resources :tags, only: [:index] | |||
end | |||
resources :products, only: [:index, :show, :create, :update] do |
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 %i or %I for an array of symbols.
app/representers/tag_representer.rb
Outdated
@@ -0,0 +1,5 @@ | |||
class TagRepresenter < ApplicationDecorator | |||
property :type, getter: ->(_) {'tag'}, writeable: false |
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.
Space missing inside {.
Space missing inside }.
app/controllers/tags_controller.rb
Outdated
|
||
render json: tags | ||
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.
Extra empty line detected at class body end.
app/controllers/tags_controller.rb
Outdated
where.not(taggings: { taggable_id: id } ). | ||
order(taggings_count: :desc). | ||
limit(10). | ||
named_like(params[:q] || '') |
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.
Align named_like with ActsAsTaggableOn::Tag. on line 13.
app/controllers/tags_controller.rb
Outdated
where(taggings: { taggable_type: type } ). | ||
where.not(taggings: { taggable_id: id } ). | ||
order(taggings_count: :desc). | ||
limit(10). |
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.
Align limit with ActsAsTaggableOn::Tag. on line 13.
app/controllers/tags_controller.rb
Outdated
|
||
tags = ActsAsTaggableOn::Tag. | ||
joins(:taggings). | ||
distinct. |
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.
Align distinct with ActsAsTaggableOn::Tag. on line 13.
app/controllers/tags_controller.rb
Outdated
id = params[key].to_i | ||
|
||
tags = ActsAsTaggableOn::Tag. | ||
joins(:taggings). |
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.
Align joins with ActsAsTaggableOn::Tag. on line 13.
app/controllers/tags_controller.rb
Outdated
|
||
tags = [] | ||
|
||
if key = params.keys.find {|k| k =~ /_id\z/ } |
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.
Prefer detect over find.
Space between { and | missing.
Use String#end_with? instead of a regex match anchored to the end of the string.
app/controllers/tags_controller.rb
Outdated
#before_action -> { doorkeeper_authorize! :admin } | ||
|
||
def index | ||
puts params.inspect |
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.
Do not write to stdout. Use Rails's logger if you want to log.
app/controllers/tags_controller.rb
Outdated
@@ -0,0 +1,27 @@ | |||
class TagsController < ApplicationController | |||
#before_action -> { doorkeeper_authorize! :admin } |
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.
Missing space after #.
0d237eb
to
e2f7a09
Compare
app/controllers/tags_controller.rb
Outdated
joins(:taggings). | ||
distinct. | ||
where(taggings: { taggable_type: type } ). | ||
where.not(taggings: { taggable_id: id } ). |
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.
Space inside parentheses detected.
app/controllers/tags_controller.rb
Outdated
tags = ActsAsTaggableOn::Tag. | ||
joins(:taggings). | ||
distinct. | ||
where(taggings: { taggable_type: type } ). |
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.
Space inside parentheses detected.
Can you work with that? I'm not quite sure about the endpoint yet though. |
49fbf63
to
1fd2829
Compare
config/routes.rb
Outdated
resource :user_deposit, only: [:create], path: 'deposit' | ||
end | ||
resources :products, only: [:index, :show, :create, :update] | ||
resources :products, only: [:index, :show, :create, :update], concerns: :taggable |
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 %i or %I for an array of symbols.
Line is too long. [83/80]
config/routes.rb
Outdated
resources :identifiers, only: [:show] | ||
resources :users, only: [:show, :index, :create, :update] do | ||
resources :users, only: [:show, :index, :create, :update], concerns: :taggable do |
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 %i or %I for an array of symbols.
Unnecessary spacing detected.
Line is too long. [84/80]
swagger_model :writeProduct do | ||
property :name, :string, :optional, 'Product name' | ||
property :tags, :array, :optional, 'Tags', | ||
'items' => { 'type' => 'string' } | ||
'items' => { '$ref' => 'writeTag' } |
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.
Align the parameters of a method call if they span more than one line.
swagger_model :readTag do | ||
description 'A Product\'s or User\'s Tag' | ||
property :name, :string, :required, 'Tag name' | ||
property :occurrences, :integer, :required, 'Number of objects with this tag' |
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.
Line is too long. [81/80]
@@ -43,7 +43,7 @@ class ProductsController < ApplicationController | |||
property :quantity, :integer, :optional, 'Total quantity' | |||
property :available_quantity, :integer, :optional, 'Available quantity' | |||
property :tags, :array, :optional, 'Tags', | |||
'items' => {'type' => 'string'} | |||
'items' => {'$ref' => 'readTag'} |
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.
Align the parameters of a method call if they span more than one line.
Space inside { missing.
Space inside } missing.
app/controllers/users_controller.rb
Outdated
swagger_model :writeUser do | ||
property :name, :string, :optional, 'User name' | ||
property :tags, :array, :optional, 'Tags', | ||
'items' => { 'type' => 'string' } | ||
'items' => { '$ref' => 'writeTag' } |
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.
Align the parameters of a method call if they span more than one line.
app/controllers/users_controller.rb
Outdated
swagger_model :readTag do | ||
description 'A Product\'s or User\'s Tag' | ||
property :name, :string, :required, 'Tag name' | ||
property :occurrences, :integer, :required, 'Number of objects with this tag' |
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.
Line is too long. [81/80]
app/controllers/users_controller.rb
Outdated
@@ -37,7 +37,7 @@ class UsersController < ApplicationController | |||
property :name, :string, :optional, 'User Name' | |||
property :balance, :integer, :optional, 'User\'s balance in € cent' | |||
property :tags, :array, :optional, 'Tags', | |||
'items' => { 'type' => 'string' } | |||
'items' => { '$ref' => 'readTag' } |
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.
Align the parameters of a method call if they span more than one line.
app/representers/user_representer.rb
Outdated
skip_parse: ->(fragment:, **) { | ||
fragment['name'].blank? | ||
}, | ||
instance: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
app/representers/user_representer.rb
Outdated
collection( | ||
:tags, | ||
decorator: TagRepresenter, | ||
skip_parse: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
skip_parse: ->(fragment:, **) { | ||
fragment['name'].blank? | ||
}, | ||
instance: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
collection( | ||
:tags, | ||
decorator: TagRepresenter, | ||
skip_parse: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
swagger_model :writeProduct do | ||
property :name, :string, :optional, 'Product name' | ||
property :tags, :array, :optional, 'Tags', | ||
'items' => { 'type' => 'string' } | ||
'items' => { '$ref' => 'writeTag' } |
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.
Align the parameters of a method call if they span more than one line.
swagger_model :readTag do | ||
description 'A Product\'s or User\'s Tag' | ||
property :name, :string, :required, 'Tag name' | ||
property :occurrences, :integer, :required, 'Number of objects with this tag' |
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.
Line is too long. [81/80]
@@ -43,7 +43,7 @@ class ProductsController < ApplicationController | |||
property :quantity, :integer, :optional, 'Total quantity' | |||
property :available_quantity, :integer, :optional, 'Available quantity' | |||
property :tags, :array, :optional, 'Tags', | |||
'items' => {'type' => 'string'} | |||
'items' => {'$ref' => 'readTag'} |
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.
Align the parameters of a method call if they span more than one line.
Space inside { missing.
Space inside } missing.
app/controllers/users_controller.rb
Outdated
swagger_model :writeUser do | ||
property :name, :string, :optional, 'User name' | ||
property :tags, :array, :optional, 'Tags', | ||
'items' => { 'type' => 'string' } | ||
'items' => { '$ref' => 'writeTag' } |
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.
Align the parameters of a method call if they span more than one line.
app/controllers/users_controller.rb
Outdated
swagger_model :readTag do | ||
description 'A Product\'s or User\'s Tag' | ||
property :name, :string, :required, 'Tag name' | ||
property :occurrences, :integer, :required, 'Number of objects with this tag' |
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.
Line is too long. [81/80]
app/controllers/users_controller.rb
Outdated
@@ -37,7 +37,7 @@ class UsersController < ApplicationController | |||
property :name, :string, :optional, 'User Name' | |||
property :balance, :integer, :optional, 'User\'s balance in € cent' | |||
property :tags, :array, :optional, 'Tags', | |||
'items' => { 'type' => 'string' } | |||
'items' => { '$ref' => 'readTag' } |
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.
Align the parameters of a method call if they span more than one line.
app/representers/user_representer.rb
Outdated
skip_parse: ->(fragment:, **) { | ||
fragment['name'].blank? | ||
}, | ||
instance: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
app/representers/user_representer.rb
Outdated
collection( | ||
:tags, | ||
decorator: TagRepresenter, | ||
skip_parse: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
skip_parse: ->(fragment:, **) { | ||
fragment['name'].blank? | ||
}, | ||
instance: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
collection( | ||
:tags, | ||
decorator: TagRepresenter, | ||
skip_parse: ->(fragment:, **) { |
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 the lambda method for multiline lambdas.
b75e0a7
to
7b54d7e
Compare
config/routes.rb
Outdated
end | ||
resources :transactions, only: [:index, :show] do | ||
resources :products, only: %i(index show create update), | ||
concerns: :taggable |
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.
Align the elements of a hash literal if they span more than one line.
config/routes.rb
Outdated
resource :cart_payment, only: [:create], path: 'pay' | ||
resources :identifiers, only: :show | ||
resources :users, only: %i(show index create update), | ||
concerns: :taggable do |
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.
Align the elements of a hash literal if they span more than one line.
ce80c75
to
f1385b1
Compare
app/controllers/users_controller.rb
Outdated
property :identifiers, :array, :optional, 'Identifiers', | ||
'items' => { '$ref' => 'writeIdentifier' } | ||
'items' => { '$ref' => 'writeIdentifier' } |
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.
Align the parameters of a method call if they span more than one line.
f1385b1
to
3ac1220
Compare
3ac1220
to
01699ee
Compare
WIP