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

Allow LATEST in get_limits #683

Merged
merged 7 commits into from
May 26, 2023
Merged

Allow LATEST in get_limits #683

merged 7 commits into from
May 26, 2023

Conversation

jmthomas
Copy link
Member

closes #679

@jmthomas jmthomas requested a review from ryanmelt May 25, 2023 14:58
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (860417e) 70.80% compared to head (3b7d393) 70.80%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #683   +/-   ##
=======================================
  Coverage   70.80%   70.80%           
=======================================
  Files         471      471           
  Lines       30216    30232   +16     
  Branches      822      822           
=======================================
+ Hits        21394    21406   +12     
- Misses       8738     8741    +3     
- Partials       84       85    +1     
Flag Coverage Δ
frontend 58.60% <ø> (-0.07%) ⬇️
ruby-backend 78.15% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
openc3/lib/openc3/api/limits_api.rb 98.85% <100.00%> (+0.10%) ⬆️
openc3/lib/openc3/api/tlm_api.rb 98.99% <100.00%> (-0.01%) ⬇️
openc3/lib/openc3/models/cvt_model.rb 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

TargetModel.packets(target_name, scope: scope).each do |packet|
item = packet['items'].find { |item| item['name'] == item_name }
if item
# TODO: Fixme: This should be using the CVT not topics - Will possibly choose wrong packet if mixed with stored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like a good opportunity to fix this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write that comment and I'm not sure what it means. The topic returns the time which we use to find 'latest'. The CvtModel only returns values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CVT stores the most recent of each packet. The problem with topics is that they contain both realtime and stored data. Whenever you use Topics you have to make sure the data you use isn't stored, and we aren't doing that here.

TargetModel.packets(target_name, scope: scope).each do |packet|
item = packet['items'].find { |item| item['name'] == item_name }
if item
hash = JSON.parse(Store.hget("#{scope}__tlm__#{target_name}", packet['packet_name']), :allow_nan => true, :create_additions => true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be a CvtModel method.

requested_item = nil
if packet_name == 'LATEST'
latest = -1
TargetModel.packets(target_name, scope: scope).each do |packet|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole loop should be a CvtModel or TargetModel method to get the latest item.

@jmthomas jmthomas merged commit 598259d into main May 26, 2023
@jmthomas jmthomas deleted the get_limits branch May 26, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow get_limits to use LATEST
2 participants