Skip to content

Conversation

@IlinDmitry
Copy link

Hello.
Nice issue for newby web programmers like me.

Copy link
Member

@davydovanton davydovanton left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.

First of all: thanks for this great contribution 👍
Also, could you add some screenshots before merge and also fix style issues?

end

def limit
10
Copy link
Member

Choose a reason for hiding this comment

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

let's make limit as 50?

def call(params)
@tasks = TaskRepository.new.find_by(search_params)
repo = TaskRepository.new.find_by(search_params)
@tasks = all_for_page(repo)
Copy link
Member

Choose a reason for hiding this comment

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

it's not a repo 🤔
let's rename it to relation

end

def pagination
html.div(class: 'pagination') do
Copy link
Member

Choose a reason for hiding this comment

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

we really need all this code without any specs here?

Copy link
Author

Choose a reason for hiding this comment

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

I wrote this code, because pagination function was not available in hanami-pagination gem.
Now i replaced it with gem function.


def find_by(params = {})
tasks.where(params).order { id.desc }.map_to(Task).to_a
tasks.where(params).order { id.desc }.map_to(Task)
Copy link
Member

Choose a reason for hiding this comment

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

WDYT if we split this code into two methods:

def find_by(params = {})
  search_relation(params).to_a
end

def search_relation(params)
  tasks.where(params).order { id.desc }.map_to(Task)
end

end

it 'returns 10 tasks on page' do

Copy link
Member

Choose a reason for hiding this comment

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

missing space here

end
end

context 'when are on the first page' do
Copy link
Member

Choose a reason for hiding this comment

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

let's simplify specs here. For this we can use DI (dependency injection and wiki) for repository instance:

So, I found a problem in pagination davydovanton/hanami-pagination#10, thanks for this! 💯 🌟 🎉


end


Copy link
Member

Choose a reason for hiding this comment

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

could you cut unnecessary spaces here and format specs? thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Ok, i will focus on it more.

@IlinDmitry
Copy link
Author

Hi.
Could you tell me please, what kind of style issues? i don't see any problem with css.
2page
1page

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.

2 participants