Skip to content

Commit

Permalink
fix: sort hosts by last_updated in buckets store, so that the first h…
Browse files Browse the repository at this point in the history
…ost is probably the primary one
  • Loading branch information
ErikBjare committed Nov 19, 2023
1 parent 54be44d commit fcbd586
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/stores/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ export const useBucketsStore = defineStore('buckets', {
}),

getters: {
hosts(this: State): string[] {
hosts(state: State): string[] {
// TODO: Include consideration of device_id UUID
return _.uniq(_.map(this.buckets, bucket => bucket.hostname || bucket.data.hostname));
let hosts = _.uniq(_.map(state.buckets, bucket => bucket.hostname || bucket.data.hostname));
// sort by last_updated, such that the most recently updated host is first (likely the current host)
hosts = _.orderBy(
hosts,
host => _.max(_.map(this.bucketsByHostname[host], b => b.last_updated)),
['desc']
);
return hosts;
},
// Uses device_id instead of hostname
devices(this: State): string[] {
Expand Down

1 comment on commit fcbd586

@github-actions
Copy link

Choose a reason for hiding this comment

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

Here are screenshots of this commit:

Screenshots using aw-server v0.12.3b11 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.12.3b11 (click to expand)

Please sign in to comment.