<commit_before>﻿/// <reference path='typings/jquery/jquery.d.ts' />
/// <reference path='typings/vss.d.ts' />

import VssService = require("VSS/Service");
import TfsWitApi = require("TFS/WorkItemTracking/RestClient");
import WitTrackingTypes = require("TFS/WorkItemTracking/Contracts");
import AuthenticationService = require("VSS/Authentication/Services");

module TechCamp.Demo {
    export interface ICreatedTaskInfo {
        title: string;
        parentId: number;
    }

    export class TaskGenerator {
        container: JQuery;
        witClient: TfsWitApi.WorkItemTrackingHttpClient;
        workItemId: number;
        tasks: Array<ICreatedTaskInfo>;
        linkTypes: any;

        constructor(container: JQuery) {
            this.container = container;
            this.witClient = VssService.getCollectionClient(TfsWitApi.WorkItemTrackingHttpClient);
            this.workItemId = VSS.getConfiguration().action.workItemId;
            //this.tasks = new Array();
            var self = this;
            this.witClient.getRelationTypes().then((linkTypes) => self.linkTypes = linkTypes);
        }

        processPbiDescription() {
            var self = this;
            self.tasks = new Array();

            var processTaskLines = (wit: WitTrackingTypes.WorkItem) => {
                var internalTasks = new Array();
                //parse description into tasks
                var description = wit.fields["System.Description"];
                description = description.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/<div>/g, "").replace(/<\/div>/g, "").replace(/&quot;/g, "");

                var taskLines = description.split("TASK ");
                taskLines.forEach((taskLine) => {
                    if (taskLine !== "") {
                        var title = taskLine;
                        internalTasks.push({ title: title, parentId: wit.id });
                    }
                });

                //Process relations to see if any task has been already added
                var processRelations = (witRelations) => {
                    if (witRelations.relations == null) {
                        return witRelations;
                    }
                    var workItemIds = new Array();

                    //Extract the work item ids from related items
                    for (var i = 0; i < witRelations.relations.length; i++) {
                        //TODO: also check that type is Task
                        var tempId = witRelations.relations[i].url.match("[^/]+$");
                        if (self.getLinkTypeName(witRelations.relations[i].rel) === "Child") {
                            var relatedWorkItemId = tempId[0];<commit_msg>bugfix for #65<commit_after>﻿/// <reference path='typings/jquery/jquery.d.ts' />
/// <reference path='typings/vss.d.ts' />

import VssService = require("VSS/Service");
import TfsWitApi = require("TFS/WorkItemTracking/RestClient");
import WitTrackingTypes = require("TFS/WorkItemTracking/Contracts");
import AuthenticationService = require("VSS/Authentication/Services");

module TechCamp.Demo {
    export interface ICreatedTaskInfo {
        title: string;
        parentId: number;
    }

    export class TaskGenerator {
        container: JQuery;
        witClient: TfsWitApi.WorkItemTrackingHttpClient;
        workItemId: number;
        tasks: Array<ICreatedTaskInfo>;
        linkTypes: any;

        constructor(container: JQuery) {
            this.container = container;
            this.witClient = VssService.getCollectionClient(TfsWitApi.WorkItemTrackingHttpClient);
            this.workItemId = VSS.getConfiguration().action.workItemId;
            //this.tasks = new Array();
            var self = this;
            this.witClient.getRelationTypes().then((linkTypes) => self.linkTypes = linkTypes);
        }

        processPbiDescription() {
            var self = this;
            self.tasks = new Array();

            var processTaskLines = (wit: WitTrackingTypes.WorkItem) => {
                var internalTasks = new Array();
                //parse description into tasks
                var description = wit.fields["System.Description"];
                description = description.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/<div>/g, "").replace(/<\/div>/g, "").replace(/&quot;/g, "");

                var taskLines = description.split("TASK ");
                taskLines.forEach((taskLine) => {
                    if (taskLine !== "") {
                        var title = taskLine;
                        internalTasks.push({ title: title, parentId: wit.id });
                    }
                });

                //Process relations to see if any task has been already added
                var processRelations = (witRelations) => {
                    if (witRelations.relations == null && internalTasks.length === 0) {
                        return witRelations;
                    }
                    var workItemIds = new Array();

                    //Extract the work item ids from related items
                    for (var i = 0; i < witRelations.relations.length; i++) {
                        //TODO: also check that type is Task
                        var tempId = witRelations.relations[i].url.match("[^/]+$");
                        if (self.getLinkTypeName(witRelations.relations[i].rel) === "Child") {
                            var relatedWorkItemId = tempId[0];
{'fraction_non_alphanumeric': 0.12116197830483545, 'fraction_numerical': 0.001287001287001287, 'mean_word_length': 1.8362877997914495, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '2466130', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1367, 'n_words': 307}