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

Ability to set timeframe for /tag/____ pages #2439

Open
2 of 4 tasks
jywarren opened this issue Mar 7, 2018 · 22 comments
Open
2 of 4 tasks

Ability to set timeframe for /tag/____ pages #2439

jywarren opened this issue Mar 7, 2018 · 22 comments
Labels
break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute HTML metrics helping to understand our community Ruby

Comments

@jywarren
Copy link
Member

jywarren commented Mar 7, 2018

We have these great pages to show activity on a topic:

https://publiclab.org/tag/data-logging

image

However, sometimes we want to be able to see this for a given time period, to understand community growth in that timeframe, kind of like on GitHub Pulse:

https://github.com/publiclab/plots2/pulse/monthly vs.

https://github.com/publiclab/plots2/pulse/weekly

That looks like this (so we may need to set an interface, but for now let's just focus on the pages)

screen shot 2018-03-07 at 10 17 08 am

We have these great stats pages where you can set a range: https://publiclab.org/stats/range/10-05-2015/10-05-2016/

The code for that (for example) is:

def range
@start = params[:start] ? Time.parse(params[:start]) : Time.now - 1.month
@end = params[:end] ? Time.parse(params[:end]) : Time.now
@notes = Node.select(%i(created type status))
.where(type: 'note', status: 1, created: @start.to_i..@end.to_i)
.count(:all)
@wikis = Revision.select(:timestamp)
.where(timestamp: @start.to_i..@end.to_i)
.count - @notes # because notes each have one revision
@people = User.where(created_at: @start..@end)
.joins('INNER JOIN users ON users.uid = rusers.id')
.where('users.status = 1')
.count
@answers = Answer.where(created_at: @start..@end)
.count
@comments = Comment.select(:timestamp)
.where(timestamp: @start.to_i..@end.to_i)
.count
@questions = Node.questions.where(status: 1, created: @start.to_i..@end.to_i)
.count
@contributors = User.contributor_count_for(@start,@end)
end

Next steps

This could be solved in a few steps, and the first might be to create a new Tag controller action like:

@jywarren jywarren added enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby HTML labels Mar 7, 2018
@rishabhptr
Copy link
Contributor

@jywarren Can I try this?

@jywarren
Copy link
Member Author

jywarren commented Mar 7, 2018 via email

@ebarry
Copy link
Member

ebarry commented Mar 7, 2018

This will assist with metrics and evaluation, thank you!

@ebarry ebarry added the metrics helping to understand our community label Mar 7, 2018
@jywarren
Copy link
Member Author

Hi @rishabhptr how is this coming? Thanks!

@rishabhptr
Copy link
Contributor

Hey, I will make a pr with initial implementation for time ranges in a day or two for you to review. Thanks!

@rishabhptr
Copy link
Contributor

Hey, as mentioned in the issue we need to create a new action for this instead of using optional parameters for dates in the original show action for tag. So what would be the response for the example request, the show page which resources filtered within the range or any new page with more descriptive information just like the stats page. Thanks 😄

@jywarren
Copy link
Member Author

jywarren commented Apr 8, 2018

I think we can re-use the show template but add a line that displays the date range specified. Make sense? Thank you! This is exciting!

@jywarren
Copy link
Member Author

jywarren commented Apr 8, 2018

And I wonder if we can add an optional filter to the ActiveRecord queries in the same action, rather than making a new action? We could add it after this line, and the matching one from the wildcard section above it:

.where('term_data.name = ? OR term_data.parent = ?', params[:id], params[:id])

We'd want to limit range based on, i guess, node creation date?

@rishabhptr
Copy link
Contributor

Yes, that was exactly my thought, instead of new action we can use the same action with optional start and end parameters. Already the show method is quite detailed and good in finding different nodes for a tag and so it would avoid redundancy of the code and layout.
So I think I can go ahead with changes in the controller and then we can add the interface from which user can select and view data for a specific date range. Thanks for the help clarifying the issue! 😄

@jywarren
Copy link
Member Author

jywarren commented Apr 12, 2018 via email

@jywarren
Copy link
Member Author

We should also plan ahead to make the graph reflect the period of time shown. Looking good!!

@rishabhptr
Copy link
Contributor

Yes, it makes sense to update the chart also maybe we can have the graph update while choosing a range from the interface much like we are doing nodes through start and end values. 😄

@jywarren jywarren added the break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration label Apr 24, 2018
@jywarren jywarren added this to the Tagging and topics milestone Apr 24, 2018
@jywarren
Copy link
Member Author

I've updated this with a checklist of sub-parts that could be broken out and solved individually. Thanks!!!

@ViditChitkara
Copy link
Member

This one seems interesting, @rishabhptr are you working on it?

@jywarren
Copy link
Member Author

jywarren commented Aug 2, 2018

#2618 added this nicely -- see:

But we need a few more things here --

@ViditChitkara what do you think?

@ViditChitkara
Copy link
Member

@jywarren Great checklist!! Would be happy to implement this step by step!! Thanks!

@jywarren
Copy link
Member Author

jywarren commented Aug 7, 2018

That'd be amazing, Vidit. Thanks!

@jywarren
Copy link
Member Author

jywarren commented Sep 5, 2018

Adding a new FTO for the range buttons! #3298

And the others here could make good FTOs as well 👍

@jywarren
Copy link
Member Author

Right now we have this in menu items for "past month" and "past year" -- let's expand on this with more of a full date picker within the same menu!

image

@Manasa2850
Copy link
Member

@jywarren I'm not able to produce this page locally. How do I go about this?

@jywarren
Copy link
Member Author

Hi @Manasa2850 do you mean you can't access for example: http://localhost:3000/tag/spectrometry?start=07-01-2018&end=08-01-2018 ?

@jywarren
Copy link
Member Author

We may be able to look at #9256 for a quick and standard way to insert dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute HTML metrics helping to understand our community Ruby
Projects
None yet
Development

No branches or pull requests

5 participants