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

Subscription Prompt next to Topics on Dashboard #4644

Closed SidharthBansal closed 4 years ago

SidharthBansal commented 5 years ago

image

Tthis isn't like a normal view here, the view is being rendered through cache, from an entry in the database, here are the links: https://github.com/publiclab/plots2/blob/9f7cfc47ded41ed3a7370c66a9c4f7af9704af59/app/views/sidebar/_dashboard.html.erb#L38-L41

https://github.com/publiclab/plots2/blob/9f7cfc47ded41ed3a7370c66a9c4f7af9704af59/app/helpers/application_helper.rb#L57-L64

So the view is rendered from the database's entry. Does this make sense?

@jywarren can you help us how we can know the tags passed in this section? We need to pass them in the Subscription button.

SidharthBansal commented 5 years ago

Part of #4131

jywarren commented 5 years ago

Hmm, I think we may need to hold on this for the time being, as I can't think of a way to do this efficiently esp if the tags are updated later.

jywarren commented 5 years ago

OK, my comment from #3932 could potentially help us prompt subscriptions for tags from another source, adding a new prompt below instead of replacing this section.

The idea is to identify tags people have been active on, but aren't subscribed to -- something like user.active_topics(limit) -- which could return a max of limit tags for:

  1. tags user is not subscribed to
  2. which occur a lot on nodes they've posted
  3. which occur a lot on nodes on which they've commented
  4. we could limit this using time if we wanted to optimize! Or cache it.

Then we'd have a list of likely candidates to prompt them to subscribe to. This is an unrelated project but could be swapped in for this one (since I agree with your comment above).

Then we could use user.active_topics to prompt users in places like the dashboard or tags page, with something like "You've been posting a lot on [air-quality]. Click here to follow that topic."

SidharthBansal commented 5 years ago

I will be working on this issue commented by Jeff.

On Fri, Jan 18, 2019, 1:23 AM Jeffrey Warren <notifications@github.com wrote:

OK, my comment from #3932 https://github.com/publiclab/plots2/issues/3932 could potentially help us prompt subscriptions for tags from another source, adding a new prompt below instead of replacing this section.

The idea is to identify tags people have been active on, but aren't subscribed to -- something like user.active_topics(limit) -- which could return a max of limit tags for:

  1. tags user is not subscribed to
  2. which occur a lot on nodes they've posted
  3. which occur a lot on nodes on which they've commented
  4. we could limit this using time if we wanted to optimize! Or cache it.

Then we'd have a list of likely candidates to prompt them to subscribe to. This is an unrelated project but could be swapped in for this one (since I agree with your comment above).

Then we could use user.active_topics to prompt users in places like the dashboard or tags page, with something like "You've been posting a lot on [air-quality]. Click here to follow that topic."

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/4644#issuecomment-455309503, or mute the thread https://github.com/notifications/unsubscribe-auth/AUACQzxYn12BbfEpPAKH0e8Xe_vyhdldks5vENStgaJpZM4aGcyJ .

SidharthBansal commented 5 years ago

@jywarren it will be really helpful if you can tell some good resources for cache management and how we do this in plots2 as I have never worked at plots2 with cache. I think it will be just a model function in tags model. It is interesting idea. You suggested me this in August but I was never able to find time on this due to gci. Will do this first.

On Fri, Jan 18, 2019, 2:01 AM Sidharth Bansal <bansal.sidharth2996@gmail.com wrote:

I will be working on this issue commented by Jeff.

On Fri, Jan 18, 2019, 1:23 AM Jeffrey Warren <notifications@github.com wrote:

OK, my comment from #3932 https://github.com/publiclab/plots2/issues/3932 could potentially help us prompt subscriptions for tags from another source, adding a new prompt below instead of replacing this section.

The idea is to identify tags people have been active on, but aren't subscribed to -- something like user.active_topics(limit) -- which could return a max of limit tags for:

  1. tags user is not subscribed to
  2. which occur a lot on nodes they've posted
  3. which occur a lot on nodes on which they've commented
  4. we could limit this using time if we wanted to optimize! Or cache it.

Then we'd have a list of likely candidates to prompt them to subscribe to. This is an unrelated project but could be swapped in for this one (since I agree with your comment above).

Then we could use user.active_topics to prompt users in places like the dashboard or tags page, with something like "You've been posting a lot on [air-quality]. Click here to follow that topic."

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/4644#issuecomment-455309503, or mute the thread https://github.com/notifications/unsubscribe-auth/AUACQzxYn12BbfEpPAKH0e8Xe_vyhdldks5vENStgaJpZM4aGcyJ .

SidharthBansal commented 5 years ago

I think

def self.related(tag_name) Rails.cache.fetch('related-tags/' + tag_name, expires_in: 1.weeks) do nids = NodeTag.joins(:tag) .where(Tag.table_name => { name: tag_name }) .select(:nid) Tag.joins(:node_tag) .where(NodeTag.table_name => { nid: nids }) .where.not(name: tag_name) .group(:tid) .order('COUNT(term_data.tid) DESC') .limit(5) end end

can help me using cache.

jywarren commented 5 years ago

This is actually a really great resource! https://guides.rubyonrails.org/caching_with_rails.html

SidharthBansal commented 5 years ago

Okay thanks I will try.

SidharthBansal commented 5 years ago

I read this two years ago. Will do a revision.

jywarren commented 4 years ago

We'll merge this into the new dashboard design which has plentiful subscription prompts! #6072 Thanks!!!