<commit_before>import { IRepository } from "../data/IRepository";
import { AbstractRepository } from "./AbstractRepository";
import { IReviewCommentEntity, ReviewCommentEntity } from "../entities/ReviewCommentEntity";
import { ReviewCommentDocument } from "../entities/documents/ReviewCommentDocument";
import { ReviewCommentSchema } from "./schemas/ReviewCommentSchema";
import { SinglePullRequestFilter } from "./filters/PullRequestFilter";
import * as BluebirdPromise from "bluebird";
import * as mongoose from "mongoose";

/**
 * IReviewCommentRepository interface.
 * Defines custom CRUD operations for a Review Comment.
 * @author <NAME> <<EMAIL>>
 */
export interface IReviewCommentRepository extends IRepository<IReviewCommentEntity, ReviewCommentDocument> {

    /**
     * Retrieves a list of review comments of a review given its GitHub id.
     * @param id        Review GitHub id.
     * @returns a promise that returns a list of review comment entities if resolved.
     */
    findByReviewId(id: number): BluebirdPromise<IReviewCommentEntity[]>;

}

/**
 * Review Comment Repository class.
 * @author <NAME> <<EMAIL>>
 */
export class ReviewCommentRepository extends AbstractRepository<IReviewCommentEntity, ReviewCommentDocument> implements IReviewCommentRepository {

    /** MongoDB collection name. */
    public static readonly COLLECTION_NAME = "review_comment";

    /**
     * Class constructor.
     * Creates the repository using the collection name and the Review Comment schema.
     * @param model     Optional mongoose model dependency injection.
     */
    constructor(model?: mongoose.Model<ReviewCommentDocument>) {
        super(ReviewCommentRepository.COLLECTION_NAME, ReviewCommentSchema.schema, model);
    }

    /**
     * Updates a Review from database. Uses its GitHub id.
     * @param item      Review entity with updated data.
     * @returns a promise that returns the number of rows affected if resolved.
     */
    public update(item: IReviewCommentEntity): BluebirdPromise<number> {
        let promise: BluebirdPromise<number> = new BluebirdPromise<number>((resolve, reject) => {
            this.model.update({ id: item.id }, item.document, (error, rowsAffected) => {
                if (!error) {
                    resolve(rowsAffected);
                } else {
                    reject(error);
                }
            });
        });
        return promise;
    }

    /**
     * Retrieves a list of review comments of a review given its GitHub id.
     * @param id        Review GitHub id.
     * @returns a promise that returns a list of review comment entities if resolved.
     */
    public findByReviewId(id: number): BluebirdPromise<IReviewCommentEntity[]> {
        let promise: BluebirdPromise<IReviewCommentEntity[]>
            = new BluebirdPromise<IReviewCommentEntity[]>((resolve, reject) => {
                this.model.find({ pull_request_review_id: id }, (error, result) => {
                    if (!error) {
                        let entityArray: IReviewEntity[] = ReviewEntity.toEntityArray(result);
                        resolve(entityArray);
                    } else {
                        reject(error);
                    }
                });
            });
        return promise;
    }
<commit_msg>fixed entity type #37.<commit_after>import { IRepository } from "../data/IRepository";
import { AbstractRepository } from "./AbstractRepository";
import { IReviewCommentEntity, ReviewCommentEntity } from "../entities/ReviewCommentEntity";
import { ReviewCommentDocument } from "../entities/documents/ReviewCommentDocument";
import { ReviewCommentSchema } from "./schemas/ReviewCommentSchema";
import { SinglePullRequestFilter } from "./filters/PullRequestFilter";
import * as BluebirdPromise from "bluebird";
import * as mongoose from "mongoose";

/**
 * IReviewCommentRepository interface.
 * Defines custom CRUD operations for a Review Comment.
 * @author <NAME> <<EMAIL>>
 */
export interface IReviewCommentRepository extends IRepository<IReviewCommentEntity, ReviewCommentDocument> {

    /**
     * Retrieves a list of review comments of a review given its GitHub id.
     * @param id        Review GitHub id.
     * @returns a promise that returns a list of review comment entities if resolved.
     */
    findByReviewId(id: number): BluebirdPromise<IReviewCommentEntity[]>;

}

/**
 * Review Comment Repository class.
 * @author <NAME> <<EMAIL>>
 */
export class ReviewCommentRepository extends AbstractRepository<IReviewCommentEntity, ReviewCommentDocument> implements IReviewCommentRepository {

    /** MongoDB collection name. */
    public static readonly COLLECTION_NAME = "review_comment";

    /**
     * Class constructor.
     * Creates the repository using the collection name and the Review Comment schema.
     * @param model     Optional mongoose model dependency injection.
     */
    constructor(model?: mongoose.Model<ReviewCommentDocument>) {
        super(ReviewCommentRepository.COLLECTION_NAME, ReviewCommentSchema.schema, model);
    }

    /**
     * Updates a Review from database. Uses its GitHub id.
     * @param item      Review entity with updated data.
     * @returns a promise that returns the number of rows affected if resolved.
     */
    public update(item: IReviewCommentEntity): BluebirdPromise<number> {
        let promise: BluebirdPromise<number> = new BluebirdPromise<number>((resolve, reject) => {
            this.model.update({ id: item.id }, item.document, (error, rowsAffected) => {
                if (!error) {
                    resolve(rowsAffected);
                } else {
                    reject(error);
                }
            });
        });
        return promise;
    }

    /**
     * Retrieves a list of review comments of a review given its GitHub id.
     * @param id        Review GitHub id.
     * @returns a promise that returns a list of review comment entities if resolved.
     */
    public findByReviewId(id: number): BluebirdPromise<IReviewCommentEntity[]> {
        let promise: BluebirdPromise<IReviewCommentEntity[]>
            = new BluebirdPromise<IReviewCommentEntity[]>((resolve, reject) => {
                this.model.find({ pull_request_review_id: id }, (error, result) => {
                    if (!error) {
                        let entityArray: IReviewCommentEntity[] = ReviewCommentEntity.toEntityArray(result);
                        resolve(entityArray);
                    } else {
                        reject(error);
                    }
                });
            });
        return promise;
    }

{'fraction_non_alphanumeric': 0.09572701192812924, 'fraction_numerical': 0.00030197795560924054, 'mean_word_length': 2.649586776859504, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 43, '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': '3733894', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1598, 'n_words': 493}