<commit_before>import {ActivatedRoute} from '@angular/router';
import {
    Change,
    DynamoResult,
    DynamoRow,
    EditorConfig,
    IgnoreCase,
    JudgementAddon,
    Report,
    Summary,
    Trial
} from '../../models/models';
import {AwsService} from '../../services/aws-service';
import {Component, ElementRef, Input, OnInit, Optional, ViewChild} from '@angular/core';
import {ObjectList} from 'aws-sdk/clients/s3';
import {LocalDataSource, ViewCell} from 'ng2-smart-table';
import {MdDialog, MdDialogRef, MdSidenav, MdSnackBar} from '@angular/material';
import * as fileSaver from 'file-saver';
import * as _ from 'lodash';
import {DetailDialogComponent} from '../detail-dialog/detail-dialog.component';
import CheckStatus, {CheckStatuses} from '../../constants/check-status';
import {SettingsService} from '../../services/settings-service';
import {createPropertyDiffs, toCheckedAlready} from '../../utils/diffs';

@Component({
    template: `
        <span [class]="status">{{renderValue}}</span>
    `,
    styles: [
        '.server-error { color: red; font-weight: bold;}',
        '.client-error { color: blue; font-weight: bold;}',
        '.success { color: green; }'
    ],
})
export class StatusCodeComponent implements ViewCell, OnInit {
    renderValue: string;
    status: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        const v = String(this.value);
        this.renderValue = v;
        this.status = v[0] === '5' ? 'server-error' :
            v[0] === '4' ? 'client-error' : 'success';
    }
}


@Component({
    template: `
        <span [title]="hoverValue">{{renderValue}}</span>
    `
})
export class HoverComponent implements ViewCell, OnInit {
    renderValue: string;
    hoverValue: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        this.renderValue = `${String(this.value).split('&').length} queries`;
        this.hoverValue = String(this.value);
    }
}

@Component({
    template: `
        <md-chip-list *ngFor="let v of this.value">
            <md-chip>{{this.v}}</md-chip>
        </md-chip-list>
    `
})
export class LabelsComponent {
    @Input() value: string[];
}

@Component({
    template: `
        <md-chip-list>
            <md-chip [color]="kind" selected="true">{{renderValue}}</md-chip>
        </md-chip-list>
    `
})
export class StatusComponent implements ViewCell, OnInit {
    renderValue: string;
    kind: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        const v = String(this.value);
        this.renderValue = v;
        this.kind = v === 'same' ? 'primary' :
            v === 'different' ? 'accent' :
                v === 'failure' ? 'warn' : '';
    }
}


const filterFunction = (v, q) =>
    q.split(' and ').every(x => {
        try {
            return x.startsWith('not ') ?
                !new RegExp(x.replace(/^not /, '')).test(v) :
                new RegExp(x).test(v);
        } catch (e) {
            return false;
        }
    });

const arrayFilterFunction = (vs: any[], q) =>
    q.split(' and ').every(x => {
        try {
            return x.startsWith('not ') ?
                !vs.every(v => new RegExp(x.replace(/^not /, '')).test(v)) :
                vs.some(v => new RegExp(x).test(v));
        } catch (e) {
            return false;
        }
    });

const TABLE_SETTINGS = {
    columns: {
        seq: {title: 'Seq', filterFunction, width: '100px'},
        name: {title: 'Name', filterFunction},
        path: {title: 'Path', filterFunction},
        status: {
            title: 'Status',<commit_msg>:skull: Fix `not` filter is not working as expected<commit_after>import {ActivatedRoute} from '@angular/router';
import {
    Change,
    DynamoResult,
    DynamoRow,
    EditorConfig,
    IgnoreCase,
    JudgementAddon,
    Report,
    Summary,
    Trial
} from '../../models/models';
import {AwsService} from '../../services/aws-service';
import {Component, ElementRef, Input, OnInit, Optional, ViewChild} from '@angular/core';
import {ObjectList} from 'aws-sdk/clients/s3';
import {LocalDataSource, ViewCell} from 'ng2-smart-table';
import {MdDialog, MdDialogRef, MdSidenav, MdSnackBar} from '@angular/material';
import * as fileSaver from 'file-saver';
import * as _ from 'lodash';
import {DetailDialogComponent} from '../detail-dialog/detail-dialog.component';
import CheckStatus, {CheckStatuses} from '../../constants/check-status';
import {SettingsService} from '../../services/settings-service';
import {createPropertyDiffs, toCheckedAlready} from '../../utils/diffs';

@Component({
    template: `
        <span [class]="status">{{renderValue}}</span>
    `,
    styles: [
        '.server-error { color: red; font-weight: bold;}',
        '.client-error { color: blue; font-weight: bold;}',
        '.success { color: green; }'
    ],
})
export class StatusCodeComponent implements ViewCell, OnInit {
    renderValue: string;
    status: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        const v = String(this.value);
        this.renderValue = v;
        this.status = v[0] === '5' ? 'server-error' :
            v[0] === '4' ? 'client-error' : 'success';
    }
}


@Component({
    template: `
        <span [title]="hoverValue">{{renderValue}}</span>
    `
})
export class HoverComponent implements ViewCell, OnInit {
    renderValue: string;
    hoverValue: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        this.renderValue = `${String(this.value).split('&').length} queries`;
        this.hoverValue = String(this.value);
    }
}

@Component({
    template: `
        <md-chip-list *ngFor="let v of this.value">
            <md-chip>{{this.v}}</md-chip>
        </md-chip-list>
    `
})
export class LabelsComponent {
    @Input() value: string[];
}

@Component({
    template: `
        <md-chip-list>
            <md-chip [color]="kind" selected="true">{{renderValue}}</md-chip>
        </md-chip-list>
    `
})
export class StatusComponent implements ViewCell, OnInit {
    renderValue: string;
    kind: string;
    @Input() value: string | number;
    @Input() rowData: any;

    ngOnInit(): void {
        const v = String(this.value);
        this.renderValue = v;
        this.kind = v === 'same' ? 'primary' :
            v === 'different' ? 'accent' :
                v === 'failure' ? 'warn' : '';
    }
}


const filterFunction = (v, q) =>
    q.split(' and ').every(x => {
        try {
            return x.startsWith('not ') ?
                (v ? !new RegExp(x.replace(/^not /, '')).test(v) : true) :
                new RegExp(x).test(v);
        } catch (e) {
            return false;
        }
    });

const arrayFilterFunction = (vs: any[], q) =>
    q.split(' and ').every(x => {
        try {
            return x.startsWith('not ') ?
                (vs.length > 0 ? !vs.every(v => new RegExp(x.replace(/^not /, '')).test(v)) : true) :
                vs.some(v => new RegExp(x).test(v));
        } catch (e) {
            return false;
        }
    });

const TABLE_SETTINGS = {
    columns: {
        seq: {title: 'Seq', filterFunction, width: '100px'},
        name: {title: 'Name', filterFunction},
        path: {title: 'Path', filterFunction},
        status: {
            title: 'Status',
{'fraction_non_alphanumeric': 0.17179072276159654, 'fraction_numerical': 0.002562028047464941, 'mean_word_length': 2.456197576887232, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1554357', 'n_tokens_mistral': 2358, 'n_tokens_neox': 2326, 'n_words': 546}