Skip to content

Commit

Permalink
[O2B-532] Improve runs overview inelastic interaction rates filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
martinboulais committed Jan 8, 2025
1 parent 4abeb49 commit 97a32c4
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
*/
import { ComparisonSelectionModel } from './ComparisonSelectionModel.js';
import { FilterInputModel } from './FilterInputModel.js';
import { FilterModel } from '../FilterModel.js';

/**
* FloatComparisonFilterModel
*/
export class FloatComparisonFilterModel extends FilterInputModel {
export class FloatComparisonFilterModel extends FilterModel {
/**
* Constructor
*/
Expand Down Expand Up @@ -67,10 +68,9 @@ export class FloatComparisonFilterModel extends FilterInputModel {
*
* @return {{ operator: string, operand: number }} current filtering parameters
*/
get value() {
get normalized() {
return {
operator: this._operatorSelectionModel.selectedOptions[0].label,
operand: this._operandInputModel.value,
[this._operatorSelectionModel.selectedOptions[0].label]: this._operandInputModel.value,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ export const inelasticInteractionRateActiveColumnsForPbPb = {
inelasticInteractionRateAvg: {
name: h('.flex-wrap', [h('', ['INEL', h('sub', 'avg')]), '(Hz)']),
format: (a) => formatFloat(a),
filter: ({ inelasticInteractionRateAvgFilterModel }) => floatNumberFilter(
inelasticInteractionRateAvgFilterModel,

/**
* Inelastic interaction rate avg filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('inelasticInteractionRateAvg'),
{ selectorPrefix: 'inelasticInteractionRateAvg' },
),
visible: true,
Expand All @@ -37,8 +44,15 @@ export const inelasticInteractionRateActiveColumnsForPbPb = {
inelasticInteractionRateAtStart: {
name: h('.flex-wrap', [h('', ['INEL', h('sub', 'start')]), '(Hz)']),
format: formatFloat,
filter: ({ inelasticInteractionRateAtStartFilterModel }) => floatNumberFilter(
inelasticInteractionRateAtStartFilterModel,

/**
* Inelastic interaction rate at start filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('inelasticInteractionRateAtStart'),
{ selectorPrefix: 'inelasticInteractionRateAtStart' },
),
visible: true,
Expand All @@ -52,8 +66,15 @@ export const inelasticInteractionRateActiveColumnsForPbPb = {
inelasticInteractionRateAtMid: {
name: h('.flex-wrap', [h('', ['INEL', h('sub', 'mid')]), '(Hz)']),
format: formatFloat,
filter: ({ inelasticInteractionRateAtMidFilterModel }) => floatNumberFilter(
inelasticInteractionRateAtMidFilterModel,

/**
* Inelastic interaction rate at start filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('inelasticInteractionRateAtMid'),
{ selectorPrefix: 'inelasticInteractionRateAtMid' },
),
visible: true,
Expand All @@ -67,8 +88,15 @@ export const inelasticInteractionRateActiveColumnsForPbPb = {
inelasticInteractionRateAtEnd: {
name: h('.flex-wrap', [h('', ['INEL', h('sub', 'end')]), '(Hz)']),
format: formatFloat,
filter: ({ inelasticInteractionRateAtEndFilterModel }) => floatNumberFilter(
inelasticInteractionRateAtEndFilterModel,

/**
* Inelastic interaction rate at start filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('inelasticInteractionRateAtEnd'),
{ selectorPrefix: 'inelasticInteractionRateAtEnd' },
),
visible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ export const inelasticInteractionRateActiveColumnsForProtonProton = {
muInelasticInteractionRate: {
name: `${GREEK_LOWER_MU_CHAR}(INEL)`,
format: formatFloat,
filter: ({ muInelasticInteractionRateFilterModel }) => floatNumberFilter(
muInelasticInteractionRateFilterModel,

/**
* Mu inelastic interaction rate filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('muInelasticInteractionRate'),
{ selectorPrefix: 'muInelasticInteractionRate' },
),
visible: true,
Expand All @@ -39,8 +46,15 @@ export const inelasticInteractionRateActiveColumnsForProtonProton = {
inelasticInteractionRateAvg: {
name: h('.flex-wrap', [h('', ['INEL', h('sub', 'avg')]), '(Hz)']),
format: (a) => formatFloat(a),
filter: ({ inelasticInteractionRateAvgFilterModel }) => floatNumberFilter(
inelasticInteractionRateAvgFilterModel,

/**
* Inelastic interaction rate avg filter component
*
* @param {RunsOverviewModel} runsOverviewModel the runs overview model
* @return {Component} the filtering component
*/
filter: (runsOverviewModel) => floatNumberFilter(
runsOverviewModel.filteringModel.get('inelasticInteractionRateAvg'),
{ selectorPrefix: 'inelasticInteractionRateAvg' },
),
visible: true,
Expand Down
94 changes: 5 additions & 89 deletions lib/public/views/Runs/Overview/RunsOverviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,13 @@ export class RunsOverviewModel extends OverviewPageModel {
runTypes: new RunTypesFilterModel(),
eorReason: new EorReasonFilterModel(),
magnets: new MagnetsFilteringModel(),
muInelasticInteractionRate: new FloatComparisonFilterModel(),
inelasticInteractionRateAvg: new FloatComparisonFilterModel(),
inelasticInteractionRateAtStart: new FloatComparisonFilterModel(),
inelasticInteractionRateAtMid: new FloatComparisonFilterModel(),
inelasticInteractionRateAtEnd: new FloatComparisonFilterModel(),
});

this._muInelasticInteractionRateFilterModel = new FloatComparisonFilterModel();
this._muInelasticInteractionRateFilterModel.observe(() => this._applyFilters());
this._muInelasticInteractionRateFilterModel.visualChange$.bubbleTo(this);

this._inelasticInteractionRateAvgFilterModel = new FloatComparisonFilterModel();
this._inelasticInteractionRateAvgFilterModel.observe(() => this._applyFilters());
this._inelasticInteractionRateAvgFilterModel.visualChange$.bubbleTo(this);

this._inelasticInteractionRateAtStartFilterModel = new FloatComparisonFilterModel();
this._inelasticInteractionRateAtStartFilterModel.observe(() => this._applyFilters());
this._inelasticInteractionRateAtStartFilterModel.visualChange$.bubbleTo(this);

this._inelasticInteractionRateAtMidFilterModel = new FloatComparisonFilterModel();
this._inelasticInteractionRateAtMidFilterModel.observe(() => this._applyFilters());
this._inelasticInteractionRateAtMidFilterModel.visualChange$.bubbleTo(this);

this._inelasticInteractionRateAtEndFilterModel = new FloatComparisonFilterModel();
this._inelasticInteractionRateAtEndFilterModel.observe(() => this._applyFilters());
this._inelasticInteractionRateAtEndFilterModel.visualChange$.bubbleTo(this);

this._filteringModel.observe(() => this._applyFilters(true));
this._filteringModel.visualChange$.bubbleTo(this);

Expand Down Expand Up @@ -203,12 +188,6 @@ export class RunsOverviewModel extends OverviewPageModel {

this._odcTopologyFullNameFilter = '';

this._muInelasticInteractionRateFilterModel.reset();
this._inelasticInteractionRateAvgFilterModel.reset();
this._inelasticInteractionRateAtStartFilterModel.reset();
this._inelasticInteractionRateAtMidFilterModel.reset();
this._inelasticInteractionRateAtEndFilterModel.reset();

if (fetch) {
this._applyFilters(true);
}
Expand All @@ -235,11 +214,6 @@ export class RunsOverviewModel extends OverviewPageModel {
|| this.dcsFilter !== ''
|| this.epnFilter !== ''
|| this._odcTopologyFullNameFilter !== ''
|| this._muInelasticInteractionRateFilterModel.isEmpty
|| this._inelasticInteractionRateAvgFilterModel.isEmpty
|| this._inelasticInteractionRateAtStartFilterModel.isEmpty
|| this._inelasticInteractionRateAtMidFilterModel.isEmpty
|| this._inelasticInteractionRateAtEndFilterModel.isEmpty;
}

/**
Expand Down Expand Up @@ -664,51 +638,6 @@ export class RunsOverviewModel extends OverviewPageModel {
return allRuns.payload.length < this._pagination.itemsCount;
}

/**
* Get muInelasticInteractionRate filter model
*
* @return {FloatComparisonFilterModel} filter model
*/
get muInelasticInteractionRateFilterModel() {
return this._muInelasticInteractionRateFilterModel;
}

/**
* Get inelasticInteractionRateAvg filter model
*
* @return {FloatComparisonFilterModel} filter model
*/
get inelasticInteractionRateAvgFilterModel() {
return this._inelasticInteractionRateAvgFilterModel;
}

/**
* Get inelasticInteractionRateAtStart filter model
*
* @return {FloatComparisonFilterModel} filter model
*/
get inelasticInteractionRateAtStartFilterModel() {
return this._inelasticInteractionRateAtStartFilterModel;
}

/**
* Get inelasticInteractionRateAtMid filter model
*
* @return {FloatComparisonFilterModel} filter model
*/
get inelasticInteractionRateAtMidFilterModel() {
return this._inelasticInteractionRateAtMidFilterModel;
}

/**
* Get inelasticInteractionRateAtEnd filter model
*
* @return {FloatComparisonFilterModel} filter model
*/
get inelasticInteractionRateAtEndFilterModel() {
return this._inelasticInteractionRateAtEndFilterModel;
}

/**
* Returns the list of URL params corresponding to the currently applied filter
*
Expand All @@ -717,13 +646,6 @@ export class RunsOverviewModel extends OverviewPageModel {
* @private
*/
_getFilterQueryParams() {
const inelFilterModels = {
muInelasticInteractionRate: this._muInelasticInteractionRateFilterModel,
inelasticInteractionRateAvg: this._inelasticInteractionRateAvgFilterModel,
inelasticInteractionRateAtStart: this._inelasticInteractionRateAtStartFilterModel,
inelasticInteractionRateAtMid: this._inelasticInteractionRateAtMidFilterModel,
inelasticInteractionRateAtEnd: this._inelasticInteractionRateAtEndFilterModel,
};
return {
...this.runFilterValues && {
'filter[runNumbers]': this.runFilterValues,
Expand Down Expand Up @@ -775,12 +697,6 @@ export class RunsOverviewModel extends OverviewPageModel {
...this._odcTopologyFullNameFilter && {
'filter[odcTopologyFullName]': this._odcTopologyFullNameFilter,
},
...Object.fromEntries(Object.entries(inelFilterModels)
.filter(([_, filterModel]) => !filterModel.isEmpty)
.map(([property, filterModel]) => [
`filter[${property}][${encodeURIComponent(filterModel.value.operator)}]`,
filterModel.value.operand,
])),
};
}

Expand Down

0 comments on commit 97a32c4

Please sign in to comment.