<commit_before>import { Meteor } from 'meteor/meteor';

import { InfoItem } from './infoitem';

export class ActionItem extends InfoItem{
    constructor(parentTopic, source) {   // constructs obj from item ID or document
        super(parentTopic, source);

        this._infoItemDoc.itemType = 'actionItem';

        if (this._infoItemDoc.isOpen == undefined) {
            this._infoItemDoc.isOpen = true;
        }
        if (this._infoItemDoc.isNew == undefined) {
            this._infoItemDoc.isNew = true;
        }
        if (this._infoItemDoc.responsible == undefined) {
            this._infoItemDoc.responsible = "";
        }
        if (this._infoItemDoc.priority == undefined) {
            this._infoItemDoc.priority = "";
        }
    }

    // ################### object methods

    invalidateIsNewFlag() {
        this._infoItemDoc.isNew = false;
    }

    isSticky() {
        return this._infoItemDoc.isOpen;
    }

    /**
     * Gets the date of the detail item
     * at the given index.
     *
     * @param index position in the details array (0 if undefined)
     * @returns {boolean|string} false (if date is not given) or date as ISO8601 string.
     */
    getDateFromDetails (index) {
        if (index === undefined) index = 0;
        let details = this._infoItemDoc.details;
        if (details.length > index && details[index].hasOwnProperty("date")) {
            return details[index].date;
        }
        return false;
    }

    /**
     * Gets the text of the detail item
     * at the given index.
     *
     * @param index position in the details array (0 if undefined)
     * @returns {string}
     */
    getTextFromDetails (index) {
        if (index === undefined) index = 0;
        let details = this._infoItemDoc.details;
        if (details.length > 0 && details[index].hasOwnProperty("text")) {
            return details[index].text;
        }
        return "";
    }

    getSubject() {
        return this._infoItemDoc.subject;
    }
<commit_msg>Minor bugfix - check if details exist before accessing them<commit_after>import { Meteor } from 'meteor/meteor';

import { InfoItem } from './infoitem';

export class ActionItem extends InfoItem{
    constructor(parentTopic, source) {   // constructs obj from item ID or document
        super(parentTopic, source);

        this._infoItemDoc.itemType = 'actionItem';

        if (this._infoItemDoc.isOpen == undefined) {
            this._infoItemDoc.isOpen = true;
        }
        if (this._infoItemDoc.isNew == undefined) {
            this._infoItemDoc.isNew = true;
        }
        if (this._infoItemDoc.responsible == undefined) {
            this._infoItemDoc.responsible = "";
        }
        if (this._infoItemDoc.priority == undefined) {
            this._infoItemDoc.priority = "";
        }
    }

    // ################### object methods

    invalidateIsNewFlag() {
        this._infoItemDoc.isNew = false;
    }

    isSticky() {
        return this._infoItemDoc.isOpen;
    }

    /**
     * Gets the date of the detail item
     * at the given index.
     *
     * @param index position in the details array (0 if undefined)
     * @returns {boolean|string} false (if date is not given) or date as ISO8601 string.
     */
    getDateFromDetails (index) {
        if (index === undefined) index = 0;
        let details = this._infoItemDoc.details;
        if (details.length > index && details[index].hasOwnProperty("date")) {
            return details[index].date;
        }
        return false;
    }

    /**
     * Gets the text of the detail item
     * at the given index.
     *
     * @param index position in the details array (0 if undefined)
     * @returns {string}
     */
    getTextFromDetails (index) {
        if (index === undefined) index = 0;
        let details = this._infoItemDoc.details;
        if (details && details.length > 0 && details[index].hasOwnProperty("text")) {
            return details[index].text;
        }
        return "";
    }

    getSubject() {
        return this._infoItemDoc.subject;
    }

{'fraction_non_alphanumeric': 0.11797890605837626, 'fraction_numerical': 0.004415011037527594, 'mean_word_length': 2.1011406844106464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5409467', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1127, 'n_words': 303}