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

Add styling and additional logic to search for users #152

Merged
merged 43 commits into from
Feb 6, 2021

Conversation

Alexander-Dubrawski
Copy link
Contributor

@Alexander-Dubrawski Alexander-Dubrawski commented Jan 23, 2021

This PR closes #127 and closes #98 .

In the navbar is now an icon that is redirecting the user to the search page.

The styling is now looking as follows:

Desktop:

Screenshot 2021-01-29 at 22 31 56

Mobile:

Screenshot 2021-01-29 at 22 08 54

@Alexander-Dubrawski Alexander-Dubrawski added the team-ε Issue assigned to Team 3 label Jan 23, 2021
@Alexander-Dubrawski Alexander-Dubrawski self-assigned this Jan 23, 2021
config/locales/en.yml Outdated Show resolved Hide resolved
app/views/layouts/_footer.html.erb Outdated Show resolved Hide resolved
app/views/layouts/_footer.html.erb Outdated Show resolved Hide resolved
app/views/layouts/_footer.html.erb Outdated Show resolved Hide resolved
app/views/layouts/_footer.html.erb Outdated Show resolved Hide resolved
Copy link
Contributor

@felixauringer felixauringer left a comment

Choose a reason for hiding this comment

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

I added some suggestions that assign the instance variables in the view as the users controller would do

spec/views/users/search.html.erb_spec.rb Outdated Show resolved Hide resolved
spec/views/users/search.html.erb_spec.rb Outdated Show resolved Hide resolved
spec/views/users/search.html.erb_spec.rb Outdated Show resolved Hide resolved
@felixauringer
Copy link
Contributor

felixauringer commented Feb 5, 2021

The code looks great now! The PR has also a size that is very good reviewable. Just one question:

  def search
    @users = User.search(params[:search]).where.not(id: current_user.id)
    @users_to_add = @users.reject do |user|
      current_user.sent_contact_request?(user)
    end
  end

It looks like users_to_add is a subset of users. Did you try out whether users that aren't contacts of (or requested by) the current user are displayed twice?
If yes, I would suggest something like the following

  def search
    other_users = User.search(params[:search]).where.not(id: current_user.id)
    @users_to_add = other_users.reject do |user|
      current_user.sent_contact_request?(user)
    end
    @users = other_users.select do |user|
      current_user.sent_contact_request?(user)
    end
  end

@Alexander-Dubrawski
Copy link
Contributor Author

The code looks great now! The PR has also a size that is very good reviewable.

Sorry for this chaotic PR of mine 🙈 . I really don't know why I implemented stuff that was already existing. But thanks for all your feedback and patience.

It looks like users_to_add is a subset of users. Did you try out whether users that aren't contacts of (or requested by) the current user are displayed twice?

You are absolutely right. Good eye. I adjusted the code.

Copy link
Contributor

@felixauringer felixauringer left a comment

Choose a reason for hiding this comment

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

Nice to finally finish this 🎉 I'm sorry for having so much comments but thank you for implementing all of it :)

@Alexander-Dubrawski Alexander-Dubrawski merged commit d560a7a into dev Feb 6, 2021
@Alexander-Dubrawski Alexander-Dubrawski deleted the Add_styling_search_for_users branch February 6, 2021 13:33
@frcroth
Copy link
Contributor

frcroth commented Feb 6, 2021

image
This is what /users/search looks for me on the deployed version

@frcroth
Copy link
Contributor

frcroth commented Feb 6, 2021

@Alexander-Dubrawski

@Alexander-Dubrawski
Copy link
Contributor Author

Alexander-Dubrawski commented Feb 6, 2021

This is what /users/search looks for me on the deployed version

I can not reproduce the error. @frcroth what exactly did you do? (For example: login, click the search icon, ...)

@felixauringer
Copy link
Contributor

image
This is what /users/search looks for me on the deployed version

Same for me, I will try to investigate the reason

@Alexander-Dubrawski
Copy link
Contributor Author

Same for me, I will try to investigate the reason

@felixauringer thanks that would be really nice. If you can not find the error, please ping me and I can also have a look this evening.

@felixauringer
Copy link
Contributor

Works locally for me, so I will have a look at the heroku logs

@felixauringer
Copy link
Contributor

The relevant part is

ActionView::Template::Error (Can't resolve image into URL: to_model delegated to attachment, but attachment is nil):

2021-02-06T15:00:46.081546+00:00 app[web.1]:      3:     <div class="container">

2021-02-06T15:00:46.081546+00:00 app[web.1]:      4:       <div class="row">

2021-02-06T15:00:46.081547+00:00 app[web.1]:      5:         <div class="col-xs">

2021-02-06T15:00:46.081548+00:00 app[web.1]:      6:           <%= image_tag user.avatar, height: 65, width: 65, class: "rounded-circle" %>

2021-02-06T15:00:46.081548+00:00 app[web.1]:      7:         </div>

2021-02-06T15:00:46.081554+00:00 app[web.1]:      8:         <a class="col-8" href=<%= user_path(user) %>>

2021-02-06T15:00:46.081555+00:00 app[web.1]:      9:           <h5 class="card-title"><%= user.display_name %></h5>

2021-02-06T15:00:46.081556+00:00 app[web.1]:   

2021-02-06T15:00:46.081556+00:00 app[web.1]:  app/views/users/_card.html.erb:6

2021-02-06T15:00:46.081556+00:00 app[web.1]:  app/views/users/search.html.erb:14

2021-02-06T15:00:46.081557+00:00 app[web.1]:  app/views/users/search.html.erb:13:in `each'

2021-02-06T15:00:46.081557+00:00 app[web.1]:  app/views/users/search.html.erb:13

@felixauringer
Copy link
Contributor

So again problems with the avatars. This PR did not touch _card.html.erb so this problem was likely there before merging this one

@felixauringer
Copy link
Contributor

That's executed on production data:

User.all.select { |user| user.avatar.nil? }.length
D, [2021-02-06T15:08:13.259421 #4] DEBUG -- :   User Load (1.8ms)  SELECT "users".* FROM "users"
=> 0

So the migration worked as expected

@felixauringer
Copy link
Contributor

I added an issue for this: #191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ε Issue assigned to Team 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Process Part] Search For Users [User Story] Search For Contacts In Mobile Version
5 participants