Skip to content

Commit

Permalink
refactor(config): Remove stats_rewrite
Browse files Browse the repository at this point in the history
The config option was invented to solve issues due to import order. Now
the order is less tangled, and the option is not needed.
  • Loading branch information
arildm committed May 22, 2024
1 parent 5c09c91 commit 7fcd4e7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Use native checkboxes in corpus chooser, not images [#362](https://github.com/spraakbanken/korp-frontend/issues/362)
- Added TypeScript definitions for Korp backend parameters and responses
- Wrapped `GraphProxy`, `KwicProxy`, `LemgramProxy`, `StatsProxy` and `TimeProxy` with factories; see [@/util/Factory](./app/scripts/util.ts)
- Removed the `stats_rewrite` config option, as the change above eliminated the need for this
- Removed globals – import them instead (or their members):
- `authenticationProxy`
- `settings`
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ const createStatisticsService = function () {
prevNonExpandedCQP,
}
let result = [e.data, columns, searchParams]
// Invoke configurable stats rewriting
if (settings["stats_rewrite"]) {
result = settings.stats_rewrite(result)
}
def.resolve(result as StatisticsWorkerResult)
}

Expand Down
3 changes: 1 addition & 2 deletions doc/frontend_devel.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ settings that affect the frontend.
- __reduce_word_attribute_selector__ - String, `union` / `intersection`. For the "compile based on" configuration in statistics, show all selected corpora *word* attributes or only the attributes common to selected corpora. **Warning:** if set to `"union"`, the statistics call will fail if user selects an attribute that is not supported by a selected corpus.
- __reduce_struct_attribute_selector__ - Same as __reduce_word_attribute_selector__, but for structural attributes.
- __statistics_search_default__ - Boolean. Decides if "Show statistics" will be checked or not when loading Korp. Default: `true`
- __stats_rewrite__: A function that takes the array `[data, columns, searchParams]`, modifies and returns it.
- __visible_modes__ - Integer. The number of modes to show links to. If there are more modes than this value, the rest will be added to a drop-down. Default: `6`
- __word_label__ - Translation object. Translations for "word". Add if you need support for other languages. Default:
```yaml
Expand Down Expand Up @@ -718,7 +717,7 @@ export default {
Rendering values and generating CQP can also be controlled by editing `app/config/statistics_config.js`, but
of course it is best to avoid editing the actual code if it is possible.

If you need to merge rows or otherwise alter the table structure, implement and assign a function to the `stats_rewrite` setting.
If you need to merge rows or otherwise alter the table structure, you can extend the `StatsProxy` class and do `statsProxyFactory.setClass(MyStatsProxy)`.

#### Stringify functions

Expand Down

0 comments on commit 7fcd4e7

Please sign in to comment.