mozilla-rally / rally-core-addon

Mozilla Public License 2.0
9 stars 13 forks source link

Enforce an order for current studies #768

Closed jepstein closed 2 years ago

jepstein commented 2 years ago

There is a no reliable way to enforce current studies because of how the data comes out of remote settings. One way to accomplish is to add a new field to remote settings. And then sort on it.

The relevant code is at https://github.com/mozilla-rally/rally-core-addon/blob/7bf4c28b4bc8ffd445137432a3792cf48adb295f/src/routes/current-studies/Content.svelte#L64

rhelmer commented 2 years ago

Since we want fine-grained control here (and the ability to do a/b-style testing here later), I think we could add a order property to the objects in public/locally-available-studies.json (and the associated schema in that same dir), then sort it (something like studies.sort((a, b) => a.order - b.order).

Ideally we should have a test here too, I'd be OK deferring that and getting this one-line out fix today, but I think it'd be pretty easy to test too.

Then to use it we'd do something like this in remote-settings:

[
  {
    "name": "First Example Study",
    [...]
    order: 1
  },
  {
    "name": "Second Example Study",
    [...]
    order: 2
  }
]

Anything missing the order property would get sorted last.

We should do the sort as close as possible to where it gets displayed IMHO, basically right above that svelte #each would be fine.

rhelmer commented 2 years ago

The basic feature is in PR #769, leaving this open because I'd like to add more test coverage.