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

Feature/systemstatus 1291 #3549

Merged
merged 9 commits into from
May 15, 2024
Merged

Feature/systemstatus 1291 #3549

merged 9 commits into from
May 15, 2024

Conversation

ashton22305
Copy link
Contributor

Work on #1291

@johrstrom
Copy link
Contributor

I know we talked on Friday - but I'm going to leave the same comments here too.

end

def node_status(cluster)
c_info = cluster_info cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use parentheses on method calls? I know Ruby allows this, but I feel like it's more readable with the enclosing ().

 c_info = cluster_info(cluster)

Comment on lines 5 to 6
url = "";
fetch(url, { headers: { Accept: "text/vnd.turbo-stream.html" } })
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this URL set to "" is a bit dangerous as this may be used in other places. I'd suggest adding the route to the app/views/layouts/_config.html.erb and then adding the corresponding method to the config.js file to extract the correct URL.

.then(response => response.ok ? Promise.resolve(response) : Promise.reject(response.text()))
.then((r) => r.text())
.then((html) => replaceHTML("system-status", html))
.then(setTimeout(poll, bcPollDelay()))
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want a new configuration for this, but let's hard code it to 30000 (30 seconds) for now.

<div class="col-sm-6 col-xs-12 p-2">
<div class="col border rounded p-2 text-center">
<h4><strong><%= title c %></strong></h4>
<div>Hello world at <%= Time.now %></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any need for this div anymore.

<% @job_clusters.each do |c| %>
<div class="col-sm-6 col-xs-12 p-2">
<div class="col border rounded p-2 text-center">
<h4><strong><%= title c %></strong></h4>
Copy link
Contributor

Choose a reason for hiding this comment

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

Be careful with headings. Semantically, they only kinda make sense if there are also h1-h3's on the page. an h4 by itself is going to throw screen reader users off if they don't see others.

If it's a sizing thing you can directly use the h4 bootstrap class to get the appropriate text size.

Comment on lines 71 to 77
active_count = 0
job_adapter(cluster).info_all_each do |i|
if i.status.running?
active_count += 1
end
end
active_count
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work as well? If you find yourself creating/defining variables outside of loops like active_count = 0, you'll often find there's a nicer way to do it in ruby.

job_adapter(cluster).info_all_each.select do |info|
  info.status.running?
end.length

"#{cluster.metadata.title.titleize} Cluster Status"
end

def generic_pct(value, total)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just call this percent right?

Comment on lines 7 to 9
@job_adapter = cluster.job_adapter
@cluster_info = @job_adapter.cluster_info
@cluster = cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want member variables in helpers. They should be treated as functional methods - i.e., they don't hold any state, are idempotent and so on.

Comment on lines 3 to 5
@job_clusters = OodAppkit.clusters
.select(&:job_allow?)
.reject { |c| c.metadata.hidden }
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you pulled this from here? Seems like we shouldn't reimplement it or in fact even need it here - the view can directly use Configuration.job_clusters.each.

def job_clusters
@job_clusters ||= OodCore::Clusters.new(
OodAppkit.clusters
.select(&:job_allow?)
.reject { |c| c.metadata.hidden }
)
end

Copy link
Contributor

@johrstrom johrstrom left a comment

Choose a reason for hiding this comment

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

Very good first start! I'll make tickets now for follow ups.

@johrstrom johrstrom self-requested a review May 15, 2024 19:07
@johrstrom johrstrom merged commit d64287d into master May 15, 2024
23 checks passed
@johrstrom johrstrom deleted the feature/systemstatus-1291 branch May 15, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants