publiclab / plots2

a collaborative knowledge-exchange platform in Rails; we welcome first-time contributors! :balloon:
https://publiclab.org
GNU General Public License v3.0
957 stars 1.83k forks source link

Add counts to `by type` dropdown on tag pages #6306

Closed jywarren closed 5 years ago

jywarren commented 5 years ago

image

On our new tag pages, let's add counts to each type in the By Type dropdown:

image

Each type can be counted a different way, and should use a 'pill badge' from the Bootstrap UI library: https://getbootstrap.com/docs/4.3/components/badge/#pill-badges

The lines where changes can be made are here:

https://github.com/publiclab/plots2/blob/69d751e2723b2d07db88cc95fd28461168f522f0/app/views/tag/show/_nav_tabs.html.erb#L10-L11

We'd love help with this! Thank you!

jywarren commented 5 years ago

Related to https://github.com/publiclab/plots2/issues/6305 too!

anna-dorigo commented 5 years ago

Hi everyone! this is my very first time helping in an open source project and I would like to help with this feature if thats ok?

jywarren commented 5 years ago

We'd love the help! However just noting that this hasn't (yet) been formatted as a first-timers-only issue so we haven't broken it down step by step. If it seems like you are comfortable taking it on, please go ahead! But if you'd like we can go through and add some more information and hints to help you out. Thanks a bunch for your help!

On Tue, Sep 17, 2019, 9:18 AM Alejandra notifications@github.com wrote:

Hi everyone! this is my very first time helping in an open source project and I would like to help with this feature if thats ok?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6J3TMEANXNO6UYV2FZDQKDKGVA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64PTMA#issuecomment-532216240, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAF6J4VUXGRMR7PCCTZQY3QKDKGVANCNFSM4IXGXSOA .

anna-dorigo commented 5 years ago

I did the fork and the clone in my computer, Im trying to get the environment running locally, I will let you guys know if I get stuck somewhere. Thanks so much for the opportunity!

jywarren commented 5 years ago

Great! There are some resources here on getting the environment running: https://github.com/publiclab/plots2/issues/3840

Thank you too!

On Tue, Sep 17, 2019 at 9:42 AM Alejandra notifications@github.com wrote:

I did the fork and the clone in my computer, Im trying to get the environment running locally, I will let you guys know if I get stuck somewhere. Thanks so much for the opportunity!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6J44JAZY3A5EXBXEZTTQKDNCVA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64SCWQ#issuecomment-532226394, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAF6J3VFTK4P23N32UGRTLQKDNCVANCNFSM4IXGXSOA .

CleverFool77 commented 5 years ago

Hi @jywarren @anna-dorigo How about showing the count in badges instead of simply displaying ? https://getbootstrap.com/docs/4.3/components/badge/

jywarren commented 5 years ago

agreed! That'd be great!

anna-dorigo commented 5 years ago

Perfect! working on it!

anna-dorigo commented 5 years ago

UPDATE: Local environment working and started diving into the code

anna-dorigo commented 5 years ago

QUESTION: Im adding dummy posts, questions and wikis to my local dababase. Im using the following suggested calls:

For this I get posts and questions added: Tag.find_nodes_by_type([tagname], 'note', false).count

For this I get 0 even though there are questions Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count

For this I get the right amount of wikis Tag.find_nodes_by_type([tagname], 'page', false).count:

Am I missing something related to the posts and questions?

here is the dump of the ActiveRecord for this call Tag.find_nodes_by_type([tagname], 'note', false).count

`#<Node nid: 50, vid: 50, type: "note", language: "", title: "hola ", uid: 1, status: 1, created: 1569251406, changed: 1569251406, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-23-2019/hola", main_image_id: nil, slug: "hola", views: 1, latitude: nil, longitude: nil, precision: nil>,

<Node nid: 48, vid: 48, type: "note", language: "", title: "hi4?", uid: 1, status: 1, created: 1568985333, changed: 1568985333, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi4", main_image_id: nil, slug: "hi4", views: 1, latitude: nil, longitude: nil, precision: nil>,

<Node nid: 47, vid: 47, type: "note", language: "", title: "hi3?", uid: 1, status: 1, created: 1568984838, changed: 1568984838, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi3", main_image_id: nil, slug: "hi3", views: 1, latitude: nil, longitude: nil, precision: nil>,

<Node nid: 45, vid: 45, type: "note", language: "", title: "hi2?", uid: 1, status: 1, created: 1568942870, changed: 1568942870, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi2", main_image_id: nil, slug: "hi2", views: 1, latitude: nil, longitude: nil, precision: nil>,

<Node nid: 44, vid: 44, type: "note", language: "", title: "hi?", uid: 1, status: 1, created: 1568942643, changed: 1568942643, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi", main_image_id: nil, slug: "hi", views: 1, latitude: nil, longitude: nil, precision: nil>]`

the nid 50 is a post and the rest are questions.

jywarren commented 5 years ago

Awesome! Uh hmmm. Are the questions tagged with question:TAGNAME appropriately?

One thing you can do is to add your test content to the test fixtures, and write a unit test in /test/unit/tag_test.rb which shows that Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count should work -- i believe there are already test "question" posts in the test fixtures as well, so you may be able to just add that unit test to confirm that it's working properly?

On Mon, Sep 23, 2019 at 11:56 AM Alejandra notifications@github.com wrote:

QUESTION: Im adding dummy posts, questions and wikis to my local dababase. Im using the following suggested calls:

For this I get posts and questions added: Tag.find_nodes_by_type([tagname], 'note', false).count

For this I get 0 even though there are questions Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count

For this I get the right amount of wikis Tag.find_nodes_by_type([tagname], 'page', false).count:

Am I missing something related to the posts and questions?

here is the dump of the ActiveRecord for this call Tag.find_nodes_by_type([tagname], 'note', false).count

<Node nid: 50, vid: 50, type: "note", language: "", title: "hola ", uid:

1, status: 1, created: 1569251406, changed: 1569251406, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-23-2019/hola", main_image_id: nil, slug: "hola", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 48, vid: 48, type: "note", language: "", title: "hi4?", uid: 1, status: 1, created: 1568985333, changed: 1568985333, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi4", main_image_id: nil, slug: "hi4", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 47, vid: 47, type: "note", language: "", title: "hi3?", uid: 1, status: 1, created: 1568984838, changed: 1568984838, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi3", main_image_id: nil, slug: "hi3", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 45, vid: 45, type: "note", language: "", title: "hi2?", uid: 1, status: 1, created: 1568942870, changed: 1568942870, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi2", main_image_id: nil, slug: "hi2", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 44, vid: 44, type: "note", language: "", title: "hi?", uid: 1, status: 1, created: 1568942643, changed: 1568942643, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi", main_image_id: nil, slug: "hi", views: 1, latitude: nil, longitude: nil, precision: nil>]

the nid 50 is a post and the rest are questions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6J4CDN2UDN5JAMY6K7DQLDRJDA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LLFMI#issuecomment-534164145, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAF6J3QYJMUBUWG3HR6FMLQLDRJDANCNFSM4IXGXSOA .

anna-dorigo commented 5 years ago

Thanks so much for your recommendation I will try that!

On Mon, Sep 23, 2019 at 12:02 PM Jeffrey Warren notifications@github.com wrote:

Awesome! Uh hmmm. Are the questions tagged with question:TAGNAME appropriately?

One thing you can do is to add your test content to the test fixtures, and write a unit test in /test/unit/tag_test.rb which shows that Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count should work -- i believe there are already test "question" posts in the test fixtures as well, so you may be able to just add that unit test to confirm that it's working properly?

On Mon, Sep 23, 2019 at 11:56 AM Alejandra notifications@github.com wrote:

QUESTION: Im adding dummy posts, questions and wikis to my local dababase. Im using the following suggested calls:

For this I get posts and questions added: Tag.find_nodes_by_type([tagname], 'note', false).count

For this I get 0 even though there are questions Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count

For this I get the right amount of wikis Tag.find_nodes_by_type([tagname], 'page', false).count:

Am I missing something related to the posts and questions?

here is the dump of the ActiveRecord for this call Tag.find_nodes_by_type([tagname], 'note', false).count

<Node nid: 50, vid: 50, type: "note", language: "", title: "hola ", uid:

1, status: 1, created: 1569251406, changed: 1569251406, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-23-2019/hola", main_image_id: nil, slug: "hola", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 48, vid: 48, type: "note", language: "", title: "hi4?", uid: 1, status: 1, created: 1568985333, changed: 1568985333, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi4", main_image_id: nil, slug: "hi4", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 47, vid: 47, type: "note", language: "", title: "hi3?", uid: 1, status: 1, created: 1568984838, changed: 1568984838, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi3", main_image_id: nil, slug: "hi3", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 45, vid: 45, type: "note", language: "", title: "hi2?", uid: 1, status: 1, created: 1568942870, changed: 1568942870, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi2", main_image_id: nil, slug: "hi2", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 44, vid: 44, type: "note", language: "", title: "hi?", uid: 1, status: 1, created: 1568942643, changed: 1568942643, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi", main_image_id: nil, slug: "hi", views: 1, latitude: nil, longitude: nil, precision: nil>]

the nid 50 is a post and the rest are questions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6J4CDN2UDN5JAMY6K7DQLDRJDA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LLFMI#issuecomment-534164145 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAAF6J3QYJMUBUWG3HR6FMLQLDRJDANCNFSM4IXGXSOA

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAJ6QINNIAR3KYA7OAE6ELDQLDR7ZA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LLYMQ#issuecomment-534166578, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ6QIOQS5YDJHQSBEJASJTQLDR7ZANCNFSM4IXGXSOA .

anna-dorigo commented 5 years ago

Hi gain Jeffrey!

You were right I need to specify in the tag for example: "question:water" that was my mistake. but is it normal that if people just add "water" without the "question:tagname" it is not considered a question anymore and is counted with the posts? shouldn't we add it in the code?

On Tue, Sep 24, 2019 at 9:03 AM Alejandra Gonzalez alejandr@gmail.com wrote:

Thanks so much for your recommendation I will try that!

On Mon, Sep 23, 2019 at 12:02 PM Jeffrey Warren notifications@github.com wrote:

Awesome! Uh hmmm. Are the questions tagged with question:TAGNAME appropriately?

One thing you can do is to add your test content to the test fixtures, and write a unit test in /test/unit/tag_test.rb which shows that Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count should work -- i believe there are already test "question" posts in the test fixtures as well, so you may be able to just add that unit test to confirm that it's working properly?

On Mon, Sep 23, 2019 at 11:56 AM Alejandra notifications@github.com wrote:

QUESTION: Im adding dummy posts, questions and wikis to my local dababase. Im using the following suggested calls:

For this I get posts and questions added: Tag.find_nodes_by_type([tagname], 'note', false).count

For this I get 0 even though there are questions Tag.find_nodes_by_type("question:#{tagname}", 'note', false).count

For this I get the right amount of wikis Tag.find_nodes_by_type([tagname], 'page', false).count:

Am I missing something related to the posts and questions?

here is the dump of the ActiveRecord for this call Tag.find_nodes_by_type([tagname], 'note', false).count

<Node nid: 50, vid: 50, type: "note", language: "", title: "hola ",

uid: 1, status: 1, created: 1569251406, changed: 1569251406, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-23-2019/hola", main_image_id: nil, slug: "hola", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 48, vid: 48, type: "note", language: "", title: "hi4?", uid: 1, status: 1, created: 1568985333, changed: 1568985333, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi4", main_image_id: nil, slug: "hi4", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 47, vid: 47, type: "note", language: "", title: "hi3?", uid: 1, status: 1, created: 1568984838, changed: 1568984838, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-20-2019/hi3", main_image_id: nil, slug: "hi3", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 45, vid: 45, type: "note", language: "", title: "hi2?", uid: 1, status: 1, created: 1568942870, changed: 1568942870, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi2", main_image_id: nil, slug: "hi2", views: 1, latitude: nil, longitude: nil, precision: nil>, #<Node nid: 44, vid: 44, type: "note", language: "", title: "hi?", uid: 1, status: 1, created: 1568942643, changed: 1568942643, comment: 2, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/notes/admin/09-19-2019/hi", main_image_id: nil, slug: "hi", views: 1, latitude: nil, longitude: nil, precision: nil>]

the nid 50 is a post and the rest are questions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6J4CDN2UDN5JAMY6K7DQLDRJDA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LLFMI#issuecomment-534164145 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAAF6J3QYJMUBUWG3HR6FMLQLDRJDANCNFSM4IXGXSOA

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAJ6QINNIAR3KYA7OAE6ELDQLDR7ZA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LLYMQ#issuecomment-534166578, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ6QIOQS5YDJHQSBEJASJTQLDR7ZANCNFSM4IXGXSOA .

anna-dorigo commented 5 years ago

Guys do you have any preference on the type of badge?

Screen Shot 2019-09-24 at 10 52 31 AM
anna-dorigo commented 5 years ago

Looking good people :)

Screen Shot 2019-09-24 at 10 57 38 AM

Do you guys want me to change the format of the "people" badge too to make it uniform?

jywarren commented 5 years ago

Sure! And, this looks epically great!

On Tue, Sep 24, 2019 at 11:00 AM Alejandra notifications@github.com wrote:

Looking good people :)

[image: Screen Shot 2019-09-24 at 10 57 38 AM] https://user-images.githubusercontent.com/1304609/65523419-3ff7d280-deba-11e9-8ac2-8a0f287b45a6.png

Do you guys want me to change the format of the "people" badge too to make it uniform?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6306?email_source=notifications&email_token=AAAF6JZNBM6ZQRQQS34BD7TQLITOTA5CNFSM4IXGXSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7OVPAA#issuecomment-534599552, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAF6J5UAN4T2GSLRH2ZATTQLITOTANCNFSM4IXGXSOA .

ebarry commented 5 years ago

Fantastic!

anna-dorigo commented 5 years ago

Hi Guys!

Im glad you guys liked it! Sorry I was away for a week, do you guys have a format in mind?

I hope to make the pull request this weekend.

jywarren commented 5 years ago

We could go for red or blue, either works for me! Thanks a lot!

anna-dorigo commented 5 years ago

Hi Guys!

I was finally able to submit the pull request. This is the final view of the UI:

Screen Shot 2019-10-12 at 11 48 13 AM

Fingers crossed everything will go smoothly!

P.D. my pleasure!! thank you so much for the opportunity!!

ebarry commented 5 years ago

This looks so good! Thank you @anna-dorigo !