Skip to content
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

Merged
merged 3 commits into from Jun 14, 2017
Merged

Tag autocompleters #96

merged 3 commits into from Jun 14, 2017

Conversation

thegcat
Copy link
Collaborator

@thegcat thegcat commented Jun 13, 2017

WIP

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

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.

@@ -0,0 +1,5 @@
class TagRepresenter < ApplicationDecorator
property :type, getter: ->(_) {'tag'}, writeable: false

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 }.


render json: tags
end

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.

where.not(taggings: { taggable_id: id } ).
order(taggings_count: :desc).
limit(10).
named_like(params[:q] || '')

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.

where(taggings: { taggable_type: type } ).
where.not(taggings: { taggable_id: id } ).
order(taggings_count: :desc).
limit(10).

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.


tags = ActsAsTaggableOn::Tag.
joins(:taggings).
distinct.

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.

id = params[key].to_i

tags = ActsAsTaggableOn::Tag.
joins(:taggings).

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.


tags = []

if key = params.keys.find {|k| k =~ /_id\z/ }

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.

#before_action -> { doorkeeper_authorize! :admin }

def index
puts params.inspect

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.

@@ -0,0 +1,27 @@
class TagsController < ApplicationController
#before_action -> { doorkeeper_authorize! :admin }

Choose a reason for hiding this comment

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

Missing space after #.

joins(:taggings).
distinct.
where(taggings: { taggable_type: type } ).
where.not(taggings: { taggable_id: id } ).

Choose a reason for hiding this comment

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

Space inside parentheses detected.

tags = ActsAsTaggableOn::Tag.
joins(:taggings).
distinct.
where(taggings: { taggable_type: type } ).

Choose a reason for hiding this comment

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

Space inside parentheses detected.

@thegcat
Copy link
Collaborator Author

thegcat commented Jun 13, 2017

Can you work with that? I'm not quite sure about the endpoint yet though.

@thegcat thegcat force-pushed the feature/95-autocomplete_for_tags branch 2 times, most recently from 49fbf63 to 1fd2829 Compare June 14, 2017 09:37
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

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

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]

@thegcat thegcat temporarily deployed to oskiosk June 14, 2017 09:47 Inactive
swagger_model :writeProduct do
property :name, :string, :optional, 'Product name'
property :tags, :array, :optional, 'Tags',
'items' => { 'type' => 'string' }
'items' => { '$ref' => 'writeTag' }

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'

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'}

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.

swagger_model :writeUser do
property :name, :string, :optional, 'User name'
property :tags, :array, :optional, 'Tags',
'items' => { 'type' => 'string' }
'items' => { '$ref' => 'writeTag' }

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'

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]

@@ -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' }

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.

skip_parse: ->(fragment:, **) {
fragment['name'].blank?
},
instance: ->(fragment:, **) {

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:, **) {

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:, **) {

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:, **) {

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' }

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'

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'}

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.

swagger_model :writeUser do
property :name, :string, :optional, 'User name'
property :tags, :array, :optional, 'Tags',
'items' => { 'type' => 'string' }
'items' => { '$ref' => 'writeTag' }

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'

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]

@@ -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' }

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.

skip_parse: ->(fragment:, **) {
fragment['name'].blank?
},
instance: ->(fragment:, **) {

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:, **) {

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:, **) {

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:, **) {

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.

@thegcat thegcat temporarily deployed to oskiosk June 14, 2017 11:54 Inactive
@thegcat thegcat force-pushed the feature/95-autocomplete_for_tags branch from b75e0a7 to 7b54d7e Compare June 14, 2017 13:12
config/routes.rb Outdated
end
resources :transactions, only: [:index, :show] do
resources :products, only: %i(index show create update),
concerns: :taggable

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

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.

@thegcat thegcat force-pushed the feature/95-autocomplete_for_tags branch from ce80c75 to f1385b1 Compare June 14, 2017 13:31
property :identifiers, :array, :optional, 'Identifiers',
'items' => { '$ref' => 'writeIdentifier' }
'items' => { '$ref' => 'writeIdentifier' }

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.

@thegcat thegcat force-pushed the feature/95-autocomplete_for_tags branch from f1385b1 to 3ac1220 Compare June 14, 2017 13:46
@thegcat thegcat force-pushed the feature/95-autocomplete_for_tags branch from 3ac1220 to 01699ee Compare June 14, 2017 13:53
@thegcat thegcat merged commit 01699ee into master Jun 14, 2017
@thegcat thegcat temporarily deployed to oskiosk June 14, 2017 13:57 Inactive
@thegcat thegcat deleted the feature/95-autocomplete_for_tags branch June 14, 2017 13:58
@thegcat thegcat mentioned this pull request Jun 14, 2017
@thegcat thegcat temporarily deployed to oskiosk June 16, 2017 10:18 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants