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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate answers model #11308

Merged
merged 7 commits into from Sep 5, 2022

Conversation

anirudhprabhakaran3
Copy link
Member

@anirudhprabhakaran3 anirudhprabhakaran3 commented Jul 26, 2022

Fixes #956

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

@anirudhprabhakaran3 anirudhprabhakaran3 requested review from a team as code owners July 26, 2022 17:23
@gitpod-io
Copy link

gitpod-io bot commented Jul 26, 2022

@@ -90,8 +90,7 @@ def recently_commented
.where(status: 1)
@pagy, @questions = pagy(filter_questions_by_tag(@questions, params[:tagnames])
.joins(:comments)
.order('comments.timestamp DESC')
.group('node.nid'), items: 24)
Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed the group function from here for two reasons:

  1. The @questions we are filtering on are already being grouped by node.nid.
  2. The MySQL issue that is coming up was that ordering was happening on a variable on which grouping is not happening.

I believe that because of this, the behaviour of the code should not change, and we should get the same results.

Copy link
Member

Choose a reason for hiding this comment

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

I think we are doing this to order it by the comment timestamps, but because nodes can have multiple comments, we had been seeing them appear more than once, so we re-added the group to ensure each node appears only once. But if you can confirm for sure that the duplication isn't happening, I like a simpler query!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm...on the data that I have I'm unable to see any duplication, but I think it is safer to keep it in that way then. I'll revert this change, thanks!

@codecov
Copy link

codecov bot commented Jul 26, 2022

Codecov Report

Merging #11308 (2f6e6a6) into main (3499c8a) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11308      +/-   ##
==========================================
+ Coverage   82.33%   82.46%   +0.12%     
==========================================
  Files          98       97       -1     
  Lines        5996     5972      -24     
==========================================
- Hits         4937     4925      -12     
+ Misses       1059     1047      -12     
Impacted Files Coverage 螖
app/api/srch/search.rb 70.51% <酶> (+3.84%) 猬嗭笍
app/models/node.rb 91.10% <酶> (-0.02%) 猬囷笍
app/controllers/application_controller.rb 90.62% <100.00%> (酶)
app/controllers/home_controller.rb 95.77% <100.00%> (-0.18%) 猬囷笍
app/models/comment.rb 77.70% <100.00%> (-0.08%) 猬囷笍
app/models/user.rb 86.49% <100.00%> (-0.15%) 猬囷笍
app/controllers/comment_controller.rb 83.07% <0.00%> (+0.26%) 猬嗭笍
app/controllers/map_controller.rb 50.33% <0.00%> (+0.33%) 猬嗭笍
app/services/execute_search.rb 94.44% <0.00%> (+5.55%) 猬嗭笍

@anirudhprabhakaran3
Copy link
Member Author

Also commenting so that there is a track on the planning issue.

#11185

@anirudhprabhakaran3
Copy link
Member Author

Hmm, I notice (nearly) all of the tests have failed. Interesting. Let me check what precisely the logs are,

@anirudhprabhakaran3
Copy link
Member Author

Looks like it is a CodeCov issue?

x> No token specified or token is empty

@jywarren could you help me out here, please? Thanks!

@jywarren
Copy link
Member

jywarren commented Aug 1, 2022

So strange. But CodeCove does get flaky sometimes. I'll try restarting it?

@jywarren
Copy link
Member

jywarren commented Aug 1, 2022

Ah wait, i now see this error:

Minitest::UnexpectedError:         ActiveRecord::StatementInvalid: Mysql2::Error: Table 'plots.answers' doesn't exist: SHOW FULL FIELDS FROM `answers`

@jywarren
Copy link
Member

jywarren commented Aug 1, 2022

I think we need to continue searching for where we depend on answers code! I mean, there are a lot: https://github.com/publiclab/plots2/search?q=answers

@jywarren
Copy link
Member

jywarren commented Aug 1, 2022

If you're not sure what to do in one of these places, feel free to leave a comment at the end of the line, and I can make a code suggestion inline in this PR!

app/controllers/home_controller.rb Outdated Show resolved Hide resolved
test/functional/api/search_api_test.rb Show resolved Hide resolved
test/functional/home_controller_test.rb Show resolved Hide resolved
test/functional/wiki_controller_test.rb Show resolved Hide resolved
test/unit/doc_result_test.rb Outdated Show resolved Hide resolved
app/controllers/home_controller.rb Outdated Show resolved Hide resolved
@@ -90,8 +90,7 @@ def recently_commented
.where(status: 1)
@pagy, @questions = pagy(filter_questions_by_tag(@questions, params[:tagnames])
.joins(:comments)
.order('comments.timestamp DESC')
.group('node.nid'), items: 24)
Copy link
Member

Choose a reason for hiding this comment

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

I think we are doing this to order it by the comment timestamps, but because nodes can have multiple comments, we had been seeing them appear more than once, so we re-added the group to ensure each node appears only once. But if you can confirm for sure that the duplication isn't happening, I like a simpler query!

@@ -126,6 +125,6 @@
</style>

<% cache('feature_home-footer', skip_digest: true) do %>
<%= feature("home-footer") %>
Copy link
Member

Choose a reason for hiding this comment

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

Hi, was this done incorrectly somehow? It might just be a feature we're not currently using. I think footer-notice is the topics table, so it might display twice if we add it here? But I could be wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Can you confirm this? Then I think we are ready to merge, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey! So in the older home.html.erb, this is there so I haven't changed it yet. Would you like me to remove this?

Reference:

<% cache('feature_home-footer', skip_digest: true) do %>
<%= feature("home-footer") %>
<% end %>

@@ -0,0 +1,5 @@
class DropAnswers < ActiveRecord::Migration[5.2]
def change
drop_table :answers
Copy link
Member

Choose a reason for hiding this comment

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

yay!

test/functional/api/search_api_test.rb Show resolved Hide resolved
test/unit/doc_result_test.rb Outdated Show resolved Hide resolved
test/functional/home_controller_test.rb Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Sep 3, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/8121896650/artifacts/351564547

@codeclimate
Copy link

codeclimate bot commented Sep 3, 2022

Code Climate has analyzed commit 2f6e6a6 and detected 0 issues on this pull request.

View more on Code Climate.

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here:
https://github.com/publiclab/plots2/suites/8121959924/artifacts/351569761

@anirudhprabhakaran3
Copy link
Member Author

All tests passing!! 馃コ 馃帀

@@ -11,7 +11,7 @@ def setup

get :home
assert_response :success
assert_select "title", Sanitize.clean('&#127880;') + (" Public Lab: #{title}")
assert_select "title", Sanitize.clean('&#127880;') + (" Public Lab: #{title}") # Test failing here
Copy link
Member

Choose a reason for hiding this comment

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

Oops just need to remove this comment!

@@ -484,7 +484,7 @@ def teardown

assert_response :success
assert_template :index
assert_select "title", Sanitize.clean('&#127880;') + (" Public Lab: Popular wiki pages")
assert_select "title", Sanitize.clean('&#127880;') + (" Public Lab: Popular wiki pages") # Test failing here
Copy link
Member

Choose a reason for hiding this comment

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

Here too!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

all good except 2 comments! Great work!

@@ -1,7 +1,6 @@
<% cache('feature_home-intro', skip_digest: true) do %>
<%= feature("home-intro") %>
<% end %>

Copy link
Member

Choose a reason for hiding this comment

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

Ah i see in the final diff nothing has changed. Thank you, just checking! Merging!

@jywarren jywarren merged commit ef4a372 into publiclab:main Sep 5, 2022
@jywarren
Copy link
Member

jywarren commented Sep 5, 2022

Great work, a big PR!!!

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.

Deprecate Drupal legacy database structures/naming
2 participants