src/lib/BatchManager.ts   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 26
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 6
mnd 2
bc 2
fnc 4
bpm 0.5
cpm 1.5
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A BatchManager.getUsableDataset 0 3 2
A BatchManager.getBoost 0 3 2
A BatchManager.insertBatch 0 3 1
A BatchManager.getBatch 0 3 1
1
import { CodeBoost } from '@/lib/CodeBoost';
2
3
export class BatchManager {
4
    public data: any[] = [];
5
6
    constructor(public filename: string, public codeboost: CodeBoost) {
7
        this.data = filename ? require(filename) : [];
8
    }
9
10
    protected getBoost(boostName: string) {
11
        return this.codeboost.getBoost(boostName);
12
    }
13
14
    public getBatch(boostName: string, size: number) {
15
        return this.getUsableDataset(boostName).slice(0, size);
16
    }
17
18
    public insertBatch(item: any) {
19
        this.data.push({ name: item });
20
    }
21
22
    public getUsableDataset(boostName: string) {
23
        return this.data.filter(repo => this.getBoost(boostName)?.canRunOnRepository(repo.name));
24
    }
25
}
26