Skip to content

Commit

Permalink
refactor(ts): statistics component
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Dec 5, 2024
1 parent b2aec82 commit 4e850a0
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 202 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Track some events with Matomo: search, language switch
- Select button in Corpus Updates section [#367](https://github.com/spraakbanken/korp-frontend/issues/367)
- KWICs opened from the statistics should only query relevant corpora [#89](https://github.com/spraakbanken/korp-frontend/issues/89)
- Alphabetic sorting of statistics columns [#37](https://github.com/spraakbanken/korp-frontend/issues/37)

### Changed

Expand Down Expand Up @@ -40,8 +41,8 @@
- The "X of Y corpora selected" phrase is not properly translated [#408](https://github.com/spraakbanken/korp-frontend/issues/408)
- Empty localization strings sometimes render as localization key [#410](https://github.com/spraakbanken/korp-frontend/issues/410)
- Wider filter lists [#412](https://github.com/spraakbanken/korp-frontend/issues/412)
- Alphabetic sorting of statistics columns [#37](https://github.com/spraakbanken/korp-frontend/issues/37)
- Show intersection in attributes instead of union in comparison view [#56](https://github.com/spraakbanken/korp-frontend/issues/56)
- Alphabetic sorting of statistics rows

## [9.7.1] - 2024-09-18

Expand Down Expand Up @@ -230,7 +231,7 @@
- On repetition error (all tokens repeat from 0), restore red outline for input
- Use `<match>` to constraint CQP subqueries (from statistics rows etc)

## [9.5.0] - 2023-01-22
## [9.5.0] - 2024-01-22

### Added

Expand Down
6 changes: 3 additions & 3 deletions app/config/statistics_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ try {
console.log("No module for statistics functions available")
}

export function getCqp(hitValues: Token[], ignoreCase: boolean): string {
export function getCqp(hitValues: Record<string, string[]>[], ignoreCase: boolean): string {
const positionalAttributes = ["word", ...Object.keys(settings.corpusListing.getCurrentAttributes())]
let hasPositionalAttributes = false

Expand Down Expand Up @@ -103,7 +103,7 @@ function reduceCqp(type: string, tokens: string[], ignoreCase: boolean): string
}

// Get the html (no linking) representation of the result for the statistics table
export function reduceStringify(type: string, values: string[], structAttr: Attribute): string {
export function reduceStringify(type: string, values: string[], structAttr?: Attribute): string {
let attrs = settings.corpusListing.getCurrentAttributes()

if (attrs[type] && attrs[type].stats_stringify) {
Expand Down Expand Up @@ -163,7 +163,7 @@ export function reduceStringify(type: string, values: string[], structAttr: Attr
var mapped = _.map(values, function (value) {
if (value === "") {
return "-"
} else if (structAttr.translation) {
} else if (structAttr?.translation) {
return locAttribute(structAttr.translation, value)
} else {
return value
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/backend/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export async function requestMapData(
cqpExprs: Record<string, string>,
within: WithinParameters,
attribute: MapAttribute,
relative: boolean
relative?: boolean
): Promise<MapRequestResult> {
const params: KorpStatsParams = {
group_by_struct: attribute.label,
Expand Down
1 change: 0 additions & 1 deletion app/scripts/components/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ angular.module("korpApp").component("results", {
columns="columns"
data="data"
error="error"
grid-data="gridData"
has-result="hasResult"
in-order="inOrder"
loading="loading"
Expand Down
Loading

0 comments on commit 4e850a0

Please sign in to comment.