<commit_before>import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import mongoose from 'mongoose';
import { Document } from 'mongoose';
import { getMongooseModule } from '../mongoose';
import Joi from '../joi';
import { Category } from './category.model';

export const ArticleJoiSchema = {
    title: Joi.string()
        .trim()
        .min(1)
        .max(80)
        .alter({
            post: (schema) => schema.required(),
        }),
    content: Joi.string()
        .trim()
        .min(1)
        .max(15000)
        .alter({
            post: (schema) => schema.required(),
        }),
    summary: Joi.string()
        .trim()
        .min(1)
        .max(1000)
        .alter({
            post: (schema) => schema.required(),
        }),
    screenshot: Joi.string()
        .trim()
        .max(100)
        .alter({
            post: (schema) => schema.required(),
        }),
    category: Joi.objectId().alter({
        post: (schema) => schema.required(),
    }),
    tags: Joi.array().items(Joi.string().max(20)),
};

export type ArticleDocument = Article & Document;

@Schema()
class DayReadings {
    @Prop({ required: true, default: 0 })
    count: number;

    @Prop({ required: true })
    timestamp: number;
}

@Schema({
    timestamps: true,
    collection: Article.name.toLocaleLowerCase(),
})
export class Article {
    _id: string;

    createdAt: string | Date;

    @Prop({ maxlength: 80, trim: true, required: true })
    title: string;

    @Prop({ maxlength: 15000, trim: true, required: true })
    content: string;

    @Prop({ maxlength: 1000, trim: true, required: true })
    summary: string;

    @Prop({ maxlength: 100, trim: true })
    screenshot: string;

    @Prop({ type: mongoose.Schema.Types.ObjectId, ref: Category.name, required: true })
    category: Category;

    @Prop({ default: 0 })
    ArticleCount: number;

    @Prop({ default: 0 })
    viewsCount: number;

    @Prop({ type: [{ type: String, maxlength: 20, lowercase: true, trim: true }], index: true })
    tags: string;

    @Prop({ default: false, select: false })
    isDeleted: boolean;

    @Prop({ default: false, select: false })
    isDraft: boolean;

    @Prop([DayReadings])
    dayReadings: DayReadings[];
}

export const ArticleSchema = SchemaFactory.createForClass(Article);

export const ArticleModelModule = getMongooseModule(Article.name, ArticleSchema);<commit_msg>fix(article.model.ts): repleace ArticleCount to commentCount<commit_after>import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import mongoose from 'mongoose';
import { Document } from 'mongoose';
import { getMongooseModule } from '../mongoose';
import Joi from '../joi';
import { Category } from './category.model';

export const ArticleJoiSchema = {
    title: Joi.string()
        .trim()
        .min(1)
        .max(80)
        .alter({
            post: (schema) => schema.required(),
        }),
    content: Joi.string()
        .trim()
        .min(1)
        .max(15000)
        .alter({
            post: (schema) => schema.required(),
        }),
    summary: Joi.string()
        .trim()
        .min(1)
        .max(1000)
        .alter({
            post: (schema) => schema.required(),
        }),
    screenshot: Joi.string()
        .trim()
        .max(100)
        .alter({
            post: (schema) => schema.required(),
        }),
    category: Joi.objectId().alter({
        post: (schema) => schema.required(),
    }),
    tags: Joi.array().items(Joi.string().max(20)),
};

export type ArticleDocument = Article & Document;

@Schema()
class DayReadings {
    @Prop({ required: true, default: 0 })
    count: number;

    @Prop({ required: true })
    timestamp: number;
}

@Schema({
    timestamps: true,
    collection: Article.name.toLocaleLowerCase(),
})
export class Article {
    _id: string;

    createdAt: string | Date;

    @Prop({ maxlength: 80, trim: true, required: true })
    title: string;

    @Prop({ maxlength: 15000, trim: true, required: true })
    content: string;

    @Prop({ maxlength: 1000, trim: true, required: true })
    summary: string;

    @Prop({ maxlength: 100, trim: true })
    screenshot: string;

    @Prop({ type: mongoose.Schema.Types.ObjectId, ref: Category.name, required: true })
    category: Category;

    @Prop({ default: 0 })
    commentCount: number;

    @Prop({ default: 0 })
    viewsCount: number;

    @Prop({ type: [{ type: String, maxlength: 20, lowercase: true, trim: true }], index: true })
    tags: string;

    @Prop({ default: false, select: false })
    isDeleted: boolean;

    @Prop({ default: false, select: false })
    isDraft: boolean;

    @Prop([DayReadings])
    dayReadings: DayReadings[];
}

export const ArticleSchema = SchemaFactory.createForClass(Article);

export const ArticleModelModule = getMongooseModule(Article.name, ArticleSchema);
{'fraction_non_alphanumeric': 0.1544314209335801, 'fraction_numerical': 0.015628213037219823, 'mean_word_length': 2.643445692883895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4529369', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1487, 'n_words': 397}