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 CSV tag and node_tag stats downloads #5412

Closed
5 tasks
first-timers bot opened this issue Apr 8, 2019 · 12 comments · Fixed by #5459
Closed
5 tasks

add CSV tag and node_tag stats downloads #5412

first-timers bot opened this issue Apr 8, 2019 · 12 comments · Fixed by #5459
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute
Milestone

Comments

@first-timers
Copy link

first-timers bot commented Apr 8, 2019

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/controllers/stats_controller.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:

@@ -100,6 +100,16 @@ def answers
     format(data, 'answers')
   end
 
+  def tag
+    data = Tag.select(:tid, :name, :parent, :count).all
+    format(data, 'tag')
+  end
+
+  def node_tag
+    data = NodeTag.select(:tid, :nid, :uid).where(date: start.to_i...fin.to_i).all
+    format(data, 'node_tag')
+  end
+
   def comments
     data = Comment.where(status: 1, timestamp: start.to_i...fin.to_i).all
     format(data, 'comment')
  • 💾 Commit your changes

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

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

  2. 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 Apr 8, 2019
@jywarren
Copy link
Member

jywarren commented Apr 8, 2019

This one is for @skilfullycurled!

@IshaGupta18
Copy link
Collaborator

@skillfullycurled we would love for you to solve this one! And don't hesitate to ask for help! Thanks.

@skilfullycurled
Copy link
Contributor

Adding in the other pieces that @jywarren wrote about in the original issue #5268

Oh sorry @skilfullycurled i didn't see this. A few thoughts that may help move it along:

  1. We should link to the outputs of the new stats downloads from https://publiclab.org/api
  2. I wonder if this is as simple as making a new route/action in this controller:

def comments
data = Comment.where(status: 1, timestamp: start.to_i...fin.to_i).all
format(data, 'comment')
end

But for the tables you're looking for: term_data and community_tags --

  def tag
    data = Tag.select(:tid, :name, :parent, :count).all
    format(data, 'tag')
  end

  def node_tag
    data = NodeTag.select(:tid, :nid, :uid).where(date: start.to_i...fin.to_i).all
    format(data, 'node_tag')
  end

Then, adding routes to match; something like these for comments:

plots2/config/routes.rb

Lines 252 to 253 in 4c6ecb2

get 'stats/comments' => 'stats#comments'
get 'stats/comments/:start/:end' => 'stats#comments'

And a link on this page to display it:

<li>
<%= link_to "Notes", stats_notes_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Wikis", stats_wikis_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Comments", stats_comments_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<li>
<%= link_to "Users", stats_users_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Asked", stats_questions_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Answered", stats_answers_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>

(although the Tag model has not timestamps, so we'd just note there that it's ALL tags)

Benjamin, this would be a pretty easy first-timers-only issue to add, i think; does this look good to you? If so, we can build an FTO from it. Thanks!

Originally posted by @jywarren in #5268 (comment)

@skilfullycurled
Copy link
Contributor

Thanks @IshaGupta18!

Okay, I made the changes. Right now it's set to draft pull request but I'm not sure if that was the correct thing to do for reasons that I explained in the comments of the request.

A follow up question, is it better to have conversations about the changes in the pull request or in this issue thread?

For example I have two questions about the changes to the stats view.

  1. The way the tags are set up in the database relationally (i.e. a list of all tags, and a list of which nodes each tag are used on) makes sense from a programmatic point of view, but I think it's a bit unexpected to the average person. I will be documenting how to merge the two after they are both downloaded, but in the meantime, I want to get some feedback on the names I've chosen for the drop down. I've titled the tags (term_data) "List of Tags", and I've titled the node_tags (community_tags) "Tag Usage". Does that make sense for the time being?

  2. I've used the following examples to make the changes to the view:

<%= link_to "Comments", stats_comments_path(format: 'csv', start: params[:start], end: params[:end]) %> 

However, with regard to the node_tags, none of the exemplars for the other downloads come from the name of a model with an underscore already in it. Is stats_node_tags_path the equivalent of stats_comments_path?

@SidharthBansal
Copy link
Member

Okay, I made the changes. Right now it's set to draft pull request but I'm not sure if that was the correct thing to do for reasons that I explained in the comments of the request.

Hi, please make the pull request at publiclab/plots2 instead of skilfullycurled/plots2?
Let's do things in baby steps.

@SidharthBansal
Copy link
Member

Best of luck 👍

@skilfullycurled
Copy link
Contributor

I think I need to turn my baby steps into infant steps. When I make the pull request from publiclab/plots2 my branch doesn't show up as an option. I can make a pull request in my own repository and choose the following options. It shows plots2 in the upper left hand corner. I'll try that...
Screen Shot 2019-04-11 at 9 16 30 AM

@skilfullycurled
Copy link
Contributor

Okay, test failed but it's easy to see why. Will fix.

@skilfullycurled
Copy link
Contributor

skilfullycurled commented Apr 11, 2019

I closed the other pull request thinking I could go back to the branch on my fork, make the changes, and then start a new one pull reqeust. Unfortunately, I am unable to commit my changes. Here's what the top and bottom of the page look like.

Screen Shot 2019-04-11 at 9 38 38 AM

Then the code where I made the edits...

Screen Shot 2019-04-11 at 9 49 21 AM

Also, if possible can you provide a few steps at a time instead of just one? Or, break down the step into even more baby steps?

Thanks for your help, everyone!

@skilfullycurled
Copy link
Contributor

skilfullycurled commented Apr 11, 2019

Okay, well I tried reading up on everything and the PR request page said to:

Add more commits by pushing to the skilfullycurled-tag-stats branch on skilfullycurled/plots2.

So I did that. The error seems to be fixed on my end. That is, when I go to the page and into the editor, the trailing white space that was causing the problem is no longer there. So, maybe that's why I can't commit because I'm not making any changes? Anyway, keep me posted on what to do next. I might just start over.

@skilfullycurled
Copy link
Contributor

skilfullycurled commented Apr 11, 2019

Ah, actually, I think I got it. I made the change before the test on a different file was done. In between making the change on the first failed test, and it finishing the tests for the other file, there was a new error. I fixed it and it's re-running the tests automatically.

@skilfullycurled
Copy link
Contributor

Checks all passed now!

I left a note for [at]publiclab/reviewers.

Anything else I can slash should do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Development

Successfully merging a pull request may close this issue.

5 participants