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

Added pagy to user tags #8635

Merged
merged 6 commits into from
Oct 20, 2020
Merged

Conversation

stacytonui
Copy link
Contributor

Fixes #8426 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@gitpod-io
Copy link

gitpod-io bot commented Oct 20, 2020

app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 20, 2020

Codecov Report

Merging #8635 into main will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8635   +/-   ##
=======================================
  Coverage   81.76%   81.76%           
=======================================
  Files         101      101           
  Lines        5901     5901           
=======================================
  Hits         4825     4825           
  Misses       1076     1076           
Impacted Files Coverage Δ
app/controllers/user_tags_controller.rb 84.28% <100.00%> (ø)

app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
app/controllers/user_tags_controller.rb Outdated Show resolved Hide resolved
@stacytonui
Copy link
Contributor Author

Hello @cesswairimu I found another paginate usage in user tags. Also, I need help in understanding the failed test. Thankyou

@cesswairimu
Copy link
Collaborator

Lets try and restart @stacytonui

@cesswairimu cesswairimu reopened this Oct 20, 2020
@gitpod-io
Copy link

gitpod-io bot commented Oct 20, 2020

@RuthNjeri
Copy link
Contributor

Hi @stacytonui the build error is related to the pagination changes.. where pagy is trying to paginate an array collection..for example

      @pagy, @user_tags = pagy(UserTag
        .select('value')
        .where("value LIKE :keyword", keyword: "%#{keyword}%")
        .group(:value)
        .order('value ASC')
        .count('value').to_a, items: 24)

When I tried running your changes on the Gitpod, I encountered the same thing...
Screenshot 2020-10-20 at 16 05 05

I looked at the documentation and pagy uses a different method to paginate an array collection..
Screenshot 2020-10-20 at 16 23 30

I made those changes on your files on Gitpod and the error I encountered was no longer there

  @pagy, @user_tags = pagy_array(UserTag
        .select('value')
        .where("value LIKE :keyword", keyword: "%#{keyword}%")
        .group(:value)
        .order('value ASC')
        .count('value').to_a, items: 24)
    elsif @toggle == "value"
      @pagy, @user_tags = pagy_array(UserTag.group(:value)
        .select('value')
        .order('value ASC')
        .count('value').to_a, items: 24)
    else # @toggle == "uses"
      @pagy, @user_tags = pagy_array(UserTag.group(:value)
        .select('value')
        .order('count_value DESC')
        .count('value').to_a, items: 24)
    end

Screenshot 2020-10-20 at 16 19 52

Note that require 'pagy/extras/array' has already been required in the pagy.rb file, all you need to do is change the methods from pagy to pagy_array

Once you do that the build will stop failing 🎉

@stacytonui
Copy link
Contributor Author

Wow @RuthNjeri such a lifesaver!..Thank you so much

@codeclimate
Copy link

codeclimate bot commented Oct 20, 2020

Code Climate has analyzed commit 9fa95a2 and detected 0 issues on this pull request.

View more on Code Climate.

@jywarren
Copy link
Member

Wow, tremendous! A tough set of changes and you got it passing the tests!

Many thanks also to @RuthNjeri for the deep research here. Great work both of you!

@jywarren jywarren merged commit 33b72fc into publiclab:main Oct 20, 2020
@jywarren
Copy link
Member

Congrats!!!

piyushswain pushed a commit to piyushswain/plots2 that referenced this pull request Oct 22, 2020
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
@ghost
Copy link

ghost commented Oct 22, 2020

Nice one @stacytonui @RuthNjeri

manchere pushed a commit to manchere/plots2 that referenced this pull request Feb 13, 2021
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
lagunasmel pushed a commit to lagunasmel/plots2 that referenced this pull request Mar 2, 2021
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
ampwang pushed a commit to ampwang/plots2 that referenced this pull request Oct 26, 2021
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* Added pagy to user tags

* Pagy

* Pagy

* Pagy

* remove whitespaces

* pagy_array
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.

Migrate to pagy
4 participants