forem.dev Community

loading...

More sidebar campaign generalisation please

lee profile image Lee ・1 min read

Would be cool if we can get this in place, I find 4 weeks for new Forems is too short.

Generalize the sidebar campaign article 'published timeframe' for smaller Forems. #11968

Currently, when you create a sidebar campaign for stories, only stories published from the last 4 weeks are counted. It would make sense for smaller communities if this were configurable in siteconfig under the admin/campaigns section as the rate of publication is much lower.

Describe the solution you'd like

The 4.weeks.ago value shown below to be set from siteconfig in admin/campains.

Additional context

The 4 week value is set in 2 places.

stories_controller.rb and in sidebars_controller.rb

` def get_latest_campaign_articles campaign_articles_scope = Article.tagged_with(Campaign.current.featured_tags, any: true) .where("published_at > ? AND score > ?", 4.weeks.ago, 0) .order(hotness_score: :desc)

requires_approval = Campaign.current.articles_require_approval?
campaign_articles_scope = campaign_articles_scope.where(approved: true) if requires_approval

@campaign_articles_count = campaign_articles_scope.count
@latest_campaign_articles = campaign_articles_scope.limit(5).pluck(:path, :title, :comments_count, :created_at)

end`

Screenshot 2020-12-18 at 09 22 34

Discussion (1)

pic
Editor guide
Collapse
lee profile image
Lee Author

Submitted a PR for this

Generalize the sidebar campaign article published timeframe for smaller forems #11996

What type of PR is this? (check all applicable)

  • [ ] Refactor
  • [x] Feature
  • [ ] Bug Fix
  • [ ] Optimization
  • [ ] Documentation Update

Description

This PR adds a configurable timeframe for showing articles in the campaign sidebar, for smaller communities, the rate of submission will be much lower therefore this allows a Forem admin to adjust the timeframe so more stories show up in the count.

Related Tickets & Documents

This is related to issue #11968

QA Instructions, Screenshots, Recordings

Enabled and create a sidebar campaign in admin/config Set the required feature tag for articles to show in the count Enabled the campaign Set the desired campaign article expiry time

Set the published time for articles within the required tag to before and after the expiry time Note the change in the Stories count.

UI accessibility concerns?

None

Added tests?

  • [x] Yes
  • [ ] No, and this is why: please replace this line with details on why tests have not been included
  • [ ] I need help with writing tests

Added to documentation?

[optional] Are there any post deployment tasks we need to perform?

Nope!

[optional] What gif best describes this PR or how it makes you feel?

am i going to expire?