cubes icon indicating copy to clipboard operation
cubes copied to clipboard

Change all model/browser object getters of named objects accept only string

Open Stiivi opened this issue 8 years ago • 2 comments

Change methods such as Cube.measure(name) to accept name only, as argument suggests. Currently all the methods accept both name and an object.

Methods to be changed:

  • [ ] Cube.measure
  • [ ] Cube.aggregate
  • [ ] Cube.dimension
  • [ ] Dimension.level
  • [ ] Dimension.hierarchy
  • [ ] Cell._dimension_cut_index
  • [ ] Cell.cut_for_dimension
  • [ ] Cell.rollup_dim

Note: eventhough this is an easy change, it might require strict assurance that we are not passing the object. This can be assured once we have all type annotations in place.

Easy but tedious.

Notes

All places where we do str(OBJECT) such as str(dimension) should be replaced with explicit attribute OBJECT.name, dimension.name instead.

Stiivi avatar Mar 11 '17 05:03 Stiivi

Giving this one a second thought: internally cubes should operate with trusted structures (already assured to be valid within the queried Cube(s) object graph), not strings. Otherwise we end up having checks all over the place. However, string based interface has it's advantages from user's perspective. It is way much simpler UI and also allows easier transformation from external representations of objects to our internal structures.

This needs better specification of the API. I'll put a draft here.

Stiivi avatar Mar 13 '17 16:03 Stiivi

This issue is also related to the Browser.aggregate() flow, which gained complexity over time. There should be better separation between user-oriented aggregate() method and actual backend-provided aggregate() (currently perform_aggregate()) that takes correct QueryContext/Query or something similar with objects guaranteed to be properly resolved and consistent.

Stiivi avatar Mar 13 '17 17:03 Stiivi