todo
- Filter by title ✅ 2023-08-08
- Enable filter clearing ✅ 2023-08-08
- Tests ✅ 2023-08-08
e.g. filter by run number
components/Filters/RunsFilter/runNumber.js
defines the filter component.
On input, it calls runModel.setRunsFilter(e.target.value)
this filter component is used in runsActiveColumns.js
which is rendered in the filtersPanel
in Runs/Overview/index.js
. the filter component is passed filteringModel, globalModel
in filtersPanel.js:41
the filteringModel is Model.runs
, or the runs model. so it calls Runs.js:389
This does this.runFilterValues = runs.trim()
, this._applyFilters()
which fetches all runs /api/runs
runs object has EORReasons
Before lunch: I added a setRunEORReasonFilter
and getRunEORReasonFilter
to the model, as well as a _runEORReasonFilter
. I added a component runEORReasonFilter.js
and an endOfRunReason
active column. This appears to display in the filters panel as well as the table. (only table if visible: false
)
So I think I’ve made the frontend? So I just need to figure out what the EOR reasons are and how they’re got from the database. I can look at the run detail page for that!
Applying filters
On each filterModel.Observe
we add a hook that calls RunsModel.fetchAllRuns()
which gets the query params by this._getFilterQueryParams
m which formats url query like so
...this.runFilterValues && {
'filter[runNumbers]': this.runFilterValues,
},
Then request /api/runs
First we have a dtoValidator
to validate the request, which uses a library called joi
.
GetRunsUsecase.execute
Recieves data type object with query, which contains filters filters extracted from this
then for each filter, make a filteringQueryBuilder
- which references columns in
Run
that satisfy some values- e.g.
filteringQueryBuilder.where('triggerValue').oneOf(...triggerValues);
- e.g.
- But for EOR reasons it’s more complicated.
- we need
eorsWithReasonsWithCategory
we want a list of EORs where thereasonType.category
matches the given category.
- we need
In eorreasonjs
we have a sequelize define and a sequelize associate. The associate builds defines a relationship between EorReason, Runs, and ReasonTypes. ReasonType
has an alias reasonType
.
In our query builder, this will find all eors with the reason type 2
const qb = new QueryBuilder().where('reasonTypeId').is('2')
const eorsWithReasonsWithCategory = await EorReasonRepository.findAll(qb)
And we get the associated runs
filteringQueryBuilder.where('id').oneOf(eorsWithReasonsWithCategory.map(({runId}) => runId))
So if we want the runId
s for eorReasons where the category
is a certain value:
const eorReasonsWithCategory = await EorReasonRepository.findAll({
attributes: ['runId'],
include: {
association: 'reasonType',
where: { category: { [Op.eq]: eor.category } },
},
});
attributes
are the columns we want from eorReasons
, association is the associatons defined sequelize associate.
Add description
- Add to form ✅ 2023-08-07
- Attach to model ✅ 2023-08-07
- include in url param ✅ 2023-08-07
- Controller, data validation ✅ 2023-08-07
- Repo ✅ 2023-08-07
- test ✅ 2023-08-08
Respond to review comments