-
Notifications
You must be signed in to change notification settings - Fork 37
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
Post news feed to user menu #1807
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1807 +/- ##
=======================================
Coverage 79.56% 79.57%
=======================================
Files 517 519 +2
Lines 40737 40770 +33
=======================================
+ Hits 32414 32441 +27
- Misses 8323 8329 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please look over comments before merging.
|
||
class NewsController < ApplicationController | ||
def index | ||
render json: OpenC3::NewsModel.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want to have an HTML version of this page too, and return either json or html based on extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a news site (https://www.openc3.com/news) so I can't imagine having another one for the little blurb news that goes in this json feed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine either way. It wouldn't really be used, just a pretty response when people poke around at the domain
this.news.forEach((news) => { | ||
news.read = true | ||
}) | ||
localStorage.newsRead = this.news.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break when we start deleting old news. Maybe use a id / timestamp from the last news item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I could grab the newest timestamp and then look to see if there is anything newer.
|
||
module OpenC3 | ||
class LocalApi | ||
include Api | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just include Api in the microservice class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to pollute the entire class just to call the one method but I guess it doesn't matter
class NewsFeed < Migration | ||
def self.run | ||
setting = SettingModel.get(name: 'news_feed') | ||
SettingModel.set({ name: 'news_feed', data: true }, scope: 'DEFAULT') unless setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this migration has issues because I'm storing true/false
in there. So this will basically always turn it on. Not sure how to check for existence vs true/false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have other true/false settings right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see the always will become true thing. You don't really need to unless part, as this should only run on migration and in that scenario the setting really shouldn't have ever existed before.
|
Pulls news from https://github.com/OpenC3/openc3-news into the backend using the
PeriodicMicroservice
which updates once per day. This pulls news from the backend every hour since we don't know when the backend news will be updated.