<commit_before>
import { PlantListService } from "./plant-list.service";
import { Plant } from "./plant";
import { Component, OnInit} from '@angular/core';
import { Params,  ActivatedRoute} from '@angular/router';
import {PlantFeedback} from "./plant.feedback";

@Component({
    selector: 'plant-component',
    templateUrl: 'plant.component.html'
})
export class PlantComponent implements OnInit {
    plant : Plant = new Plant();
    plantFeedback: PlantFeedback = new PlantFeedback();
    private commented: Boolean = false;

    // The rating field can have 3 values:
    // null - means that the plant hasn't been rated
    // true - means that the plant was liked
    // false - means the the plant was disliked
    private rating: boolean = null;

    //public plant: Plant = null;
    private id: string;
    private plantID: string;

    constructor(private plantListService: PlantListService, private route: ActivatedRoute) {
    }

    private comment(comment: string): void {
        if(!this.commented){
            if(comment != null) {
                this.plantListService.commentPlant(this.plant["_id"]["$oid"], comment)
                    .subscribe(succeeded => this.commented = succeeded);
            }
        }
    }

    private ratePlant(like: boolean): void {
        if(this.rating === null && like !== null) {
            this.plantListService.ratePlant(this.plant["_id"]["$oid"], like)
                .subscribe(succeeded => this.rating = like);
        }

        this.route.params
            .switchMap((params: Params) => this.plantListService.getFeedbackForPlantByPlantID(params['plantID']))
            .subscribe((plantFeedback: PlantFeedback) => this.plantFeedback = plantFeedback);
    }



    ngOnInit(): void {

        //This gets the ID from the URL params and sets and subscribes this.plant
        this.route.params
            .switchMap((params: Params) => this.plantListService.getPlantById(params['plantID']))
            .subscribe((plant: Plant) => this.plant = plant);
        this.route.params
            .switchMap((params: Params) => this.plantListService.getFeedbackForPlantByPlantID(params['plantID']))
            .subscribe((plantFeedback: PlantFeedback) => this.plantFeedback = plantFeedback);

    }
}<commit_msg>Add update for comment count after a comment is posted<commit_after>
import { PlantListService } from "./plant-list.service";
import { Plant } from "./plant";
import { Component, OnInit} from '@angular/core';
import { Params,  ActivatedRoute} from '@angular/router';
import {PlantFeedback} from "./plant.feedback";

@Component({
    selector: 'plant-component',
    templateUrl: 'plant.component.html'
})
export class PlantComponent implements OnInit {
    plant : Plant = new Plant();
    plantFeedback: PlantFeedback = new PlantFeedback();
    private commented: Boolean = false;

    // The rating field can have 3 values:
    // null - means that the plant hasn't been rated
    // true - means that the plant was liked
    // false - means the the plant was disliked
    private rating: boolean = null;

    //public plant: Plant = null;
    private id: string;
    private plantID: string;

    constructor(private plantListService: PlantListService, private route: ActivatedRoute) {
    }

    private comment(comment: string): void {
        if(!this.commented){
            if(comment != null) {
                this.plantListService.commentPlant(this.plant["_id"]["$oid"], comment)
                    .subscribe(succeeded => this.commented = succeeded);

                //Update comment numbers
                this.route.params
                    .switchMap((params: Params) => this.plantListService.getFeedbackForPlantByPlantID(params['plantID']))
                    .subscribe((plantFeedback: PlantFeedback) => this.plantFeedback = plantFeedback);
            }
        }
    }

    private ratePlant(like: boolean): void {
        if(this.rating === null && like !== null) {
            this.plantListService.ratePlant(this.plant["_id"]["$oid"], like)
                .subscribe(succeeded => this.rating = like);
        }

        //Update flower rating numbers
        this.route.params
            .switchMap((params: Params) => this.plantListService.getFeedbackForPlantByPlantID(params['plantID']))
            .subscribe((plantFeedback: PlantFeedback) => this.plantFeedback = plantFeedback);
    }



    ngOnInit(): void {

        //This gets the ID from the URL params and sets and asks the server for the Plant with that ID
        this.route.params
            .switchMap((params: Params) => this.plantListService.getPlantById(params['plantID']))
            .subscribe((plant: Plant) => this.plant = plant);

        //Asks the server for a PlantFeedback object corresponding
        this.route.params
            .switchMap((params: Params) => this.plantListService.getFeedbackForPlantByPlantID(params['plantID']))
            .subscribe((plantFeedback: PlantFeedback) => this.plantFeedback = plantFeedback);

    }
}
{'fraction_non_alphanumeric': 0.11940298507462686, 'fraction_numerical': 0.0003980099502487562, 'mean_word_length': 2.77610818933133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '962812', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1340, 'n_words': 355}