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

Delete answer.rb (start with deleting related code) #8512

Closed
5 tasks
first-timers bot opened this issue Oct 9, 2020 · 8 comments · Fixed by #9487
Closed
5 tasks

Delete answer.rb (start with deleting related code) #8512

first-timers bot opened this issue Oct 9, 2020 · 8 comments · Fixed by #9487
Labels
deprecation first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute

Comments

@first-timers
Copy link

first-timers bot commented Oct 9, 2020

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!

  • 📝 Update the file app/models/answer.rb in the plots2 repository (press the little pen Icon) and edit the line as shown below.

See this page for some help in taking your first steps!

Below is a "diff" showing in red (and a -) which lines to remove, and in green (and a +) which lines to add:

@@ -1,35 +0,0 @@
-class Answer < ApplicationRecord
-  include CommentsShared
-  include NodeShared
-  extend RawStats
-
-  belongs_to :node, foreign_key: 'nid'
-  belongs_to :user, foreign_key: 'uid'
-  has_many :answer_selections, foreign_key: 'aid'
-  has_many :comments, foreign_key: 'aid', dependent: :destroy
-
-  validates :content, presence: true
-
-  scope :past_week, -> { where("created_at > ?", (Time.now - 7.days)) }
-  scope :past_month, -> { where("created_at > ?", (Time.now - 1.months)) }
-
-  def body
-    finder = content.gsub(Callouts.const_get(:FINDER), Callouts.const_get(:PRETTYLINKMD))
-    finder = finder.gsub(Callouts.const_get(:HASHTAGNUMBER), Callouts.const_get(:NODELINKMD))
-    finder.gsub(Callouts.const_get(:HASHTAG), Callouts.const_get(:HASHLINKMD))
-  end
-
-  def body_markdown
-    RDiscount.new(body, :autolink).to_html
-  end
-
-  # users who like this answer
-  def likers
-    answer_selections
-      .joins(:user)
-      .references(:rusers)
-      .where(liking: true)
-      .where('rusers.status': 1)
-      .collect(&:user)
-  end
-end
  • 💾 Commit your changes

  • 🔀 Start a Pull Request. There are two ways how you can start a pull request:

  1. If you are not familiar with GitHub or the pull request model, here is a guide you can follow on how GitHub works.

  2. If you are familiar with the terminal or would like to learn to use it, here is a great tutorial on how to send a pull request using the terminal.

  3. You can also edit files directly in your browser and open a pull request from there.

  • 🏁 Done Ask in comments for a review :)

Please keep us updated

💬⏰ - We encourage contributors to be respectful to the community and provide an update within a week of claiming a first-timers-only issue. We're happy to keep it assigned to you as long as you need if you update us with a request for more time or help, but if we don't see any activity a week after you claim it we may reassign it to give someone else a chance. Thank you in advance!

If this happens to you, don't sweat it! Grab another open issue.

Is someone else already working on this?

🔗- We encourage contributors to link to the original issue in their pull request so all users can easily see if someone's already started on it.

👥- If someone seems stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!

🤔❓ Questions?

Leave a comment below!

@first-timers first-timers bot added first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute labels Oct 9, 2020
@jywarren
Copy link
Member

jywarren commented Oct 9, 2020

This also helps to complete this larger issue: #4094 as we are getting rid of the unique Answer model and all corresponding code!

This issue will also depend on #8511 to be completed before a pull request with this change will work -- because in that issue, we remove the tests that detect the presence of this code. I'm happy to help with this if any Outreachy folks would like to take it up!

@nibble0101
Copy link

@jywarren. Can I work on this?

@sagarpreet-chadha
Copy link
Contributor

Hey @nibble0101 , that would be great 🎉
Let us know if you need some help with this issue 😄

@nibble0101
Copy link

@sagarpreet-chadha Thanks will get right to it.

@Asu1996
Copy link

Asu1996 commented Oct 10, 2020

Can i do this? i am new here. (outreachy)

@nibble0101 nibble0101 mentioned this issue Oct 10, 2020
5 tasks
@avidraghav avidraghav mentioned this issue Oct 11, 2020
5 tasks
@shubhangikori shubhangikori mentioned this issue Oct 14, 2020
5 tasks
@larabee7777
Copy link
Contributor

Do you need help here?

@TildaDares
Copy link
Member

Is someone working on this issue? I'd like to take it up.

@jywarren
Copy link
Member

jywarren commented Apr 9, 2021

Hi @TildaDares it turned out this was much more complex as there were just many more instances of "answer" throughout the code and tests. I think we'd LOVE any PR which removes a mention of answer/answers from parts of our codebase. Please look through these to see if there is one and if you can open a PR, we will review it! Thank you!

I'm starting here: https://github.com/publiclab/plots2/search?q=answer

Only the Ruby ones would be essential in a first round. I'm seeing:

https://github.com/publiclab/plots2/tree/main/test/functional/questions_controller_test.rb#L69

https://github.com/publiclab/plots2/blob/main/test/unit/comment_test.rb#L157-L176

https://github.com/publiclab/plots2/blob/main/app/controllers/stats_controller.rb#L66-L72

@jywarren jywarren changed the title Delete answer.rb Delete answer.rb (start with deleting related code) Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute
Projects
None yet
6 participants