Skip to content

Commit

Permalink
changes to the ts part
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Aug 9, 2023
1 parent 007d777 commit 7e37aaa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions report-viewer/src/model/HundredValueDistribution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Distribution from './Distribution'

/**
* This class represents he JPlag Distribution of a metric.
* It is composed of 100 values, each representing the sum of the values of the metric in the corresponding percentile.
*/
export default class HundredValueDistribution extends Distribution {
constructor(distribution: number[]) {
super(distribution)
Expand Down
3 changes: 2 additions & 1 deletion report-viewer/src/model/Overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class Overview {
this._durationOfExecution = durationOfExecution
this._topComparisons = topComparisons
this._distributions = distributions
;(this._clusters = clusters), (this._totalComparisons = totalComparisons)
this._clusters = clusters
this._totalComparisons = totalComparisons
}

/**
Expand Down
4 changes: 4 additions & 0 deletions report-viewer/src/model/TenValueDistribution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Distribution from './Distribution'

/**
* This class represents he JPlag Distribution of a metric.
* It is composed of 10 values, each representing the sum of the values of the metric in the corresponding percentiles.
*/
export default class TenValueDistribution extends Distribution {
constructor(distribution: number[]) {
super(distribution)
Expand Down
13 changes: 7 additions & 6 deletions report-viewer/src/model/factories/BaseFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export class BaseFactory {
return this.getLocalFile(path)
} else if (store().state.zipModeUsed) {
const index = Object.keys(store().state.files).find((name) => name.endsWith(path))
if (index != undefined) {
const file = store().state.files[index]
if (file != undefined) {
return file
}
if (index == undefined) {
throw new Error(`Could not find ${path} in zip file.`)
}
throw new Error(`Could not find ${path} in zip file.`)
const file = store().state.files[index]
if (file == undefined) {
throw new Error(`Could not load ${path}.`)
}
return file
} else if (store().state.singleModeUsed) {
return store().state.singleFillRawContent
}
Expand Down
7 changes: 5 additions & 2 deletions report-viewer/src/model/factories/OverviewFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { BaseFactory } from './BaseFactory'
import PercentileDistribution from '../HundredValueDistribution'
import TenValueDistribution from '../TenValueDistribution'

/**
* Factory class for creating Overview objects
*/
export class OverviewFactory extends BaseFactory {
static reportViewerVersion: Version =
versionJson['report_viewer_version'] !== undefined
Expand Down Expand Up @@ -129,15 +132,15 @@ export class OverviewFactory extends BaseFactory {
const averageSimilarities: Map<string, number> = new Map<string, number>()
const comparisons = [] as Array<ComparisonListElement>

// Average
// Save the average similarities in a temporary map to combine them with the max similarities later
for (const comparison of metrics[0].topComparisons as Array<Record<string, unknown>>) {
averageSimilarities.set(
(comparison.first_submission as string) + '-' + (comparison.second_submission as string),
comparison.similarity as number
)
}

// Max
// Extract the max similarities and combine them with the average similarities
let counter = 0
for (const comparison of metrics[1].topComparisons as Array<Record<string, unknown>>) {
const avg = averageSimilarities.get(
Expand Down

0 comments on commit 7e37aaa

Please sign in to comment.