Open ericfranz opened 3 years ago
The reason this didn't work: https://github.com/CHPC-UofU/ood-systemstatus/blob/583fbabffd59139907715b52f0ac5d359f38bfb7/app.rb#L23
CLUSTERS.sort_by
will return a new array, not modify the exiting CLUSTERS objectCLUSTERS
itself is an OodCore::Clusers
object that includes the Enumerable module. But unfortunately the methods on Enumerable like sort_by return an array so in order to end up with another OodCore::Clusers
object you have to do OodCore::Clusers.new(your_clusters_array)
which is why this is what happens when defining CLUSTERS
. So Enumerable is cool cause it makes it really easy to create custom collection objects but the drawback is that the methods do not return new custom collections but arrays.Finally, above, the
.sort_by {|cluster| [- cluster.metadata.priority.to_i, cluster.id]}
is the trick for doing primary and secondary sorting in Ruby. If you only need one sort, such as priority then you do not need the array:
.sort_by {|cluster| cluster.metadata.priority.to_i }
We can modify https://github.com/CHPC-UofU/ood-systemstatus/blob/583fbabffd59139907715b52f0ac5d359f38bfb7/app.rb#L17-L20
like this:
Then in the cluster config for Kingspeak and Notchspeak if you add priority to the metadata like
This will put Kingspeak and Notchpeak on top, then sort the rest alphabetically. The cluster config filenames == the id, and since that is lowercase and starts with the same letter as the title, it works pretty well.