<commit_before>import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { ChartsService } from '../shared/services/charts.service';
import { Chart } from '../shared/models/chart';
import { MetaService } from 'ng2-meta';

@Component({
  selector: 'app-chart-details',
  templateUrl: './chart-details.component.html',
  styleUrls: ['./chart-details.component.scss']
})
export class ChartDetailsComponent implements OnInit {
  /* This resource will be different, probably ChartVersion */
  chart: Chart
  currentVersion: String

  constructor(
    private route: ActivatedRoute,
    private chartsService: ChartsService,
    private metaService: MetaService
  ) { }

  ngOnInit() {
    this.route.params.forEach((params: Params) => {
      let repo = params['repo'];
      let chartName = params['chartName']
      this.chartsService.getChart(repo, chartName)
        .subscribe(chart => {
          this.chart = chart
          this.currentVersion = params['version'] || this.chart.relationships.latestChartVersion.data.version
          this.updateMetaTags(chart);
        });
    });
  }

  /**
   * Update the metatags with the name and the description of the application.
   *
   * @param {Chart} chart The chart to get the name and the description.
   */
  updateMetaTags(chart: Chart): void {
    this.metaService.setTitle(chart.attributes.name);
    this.metaService.setTag('description', chart.attributes.description);
    this.metaService.setTag('og:title', chart.attributes.name);
    this.metaService.setTag('og:description', chart.attributes.description);
  }
}
<commit_msg>Add selected version to the title tag<commit_after>import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { ChartsService } from '../shared/services/charts.service';
import { Chart } from '../shared/models/chart';
import { MetaService } from 'ng2-meta';

@Component({
  selector: 'app-chart-details',
  templateUrl: './chart-details.component.html',
  styleUrls: ['./chart-details.component.scss']
})
export class ChartDetailsComponent implements OnInit {
  /* This resource will be different, probably ChartVersion */
  chart: Chart;
  currentVersion: string;
  titleVersion: string;

  constructor(
    private route: ActivatedRoute,
    private chartsService: ChartsService,
    private metaService: MetaService
  ) { }

  ngOnInit() {
    this.route.params.forEach((params: Params) => {
      let repo = params['repo'];
      let chartName = params['chartName']
      this.chartsService.getChart(repo, chartName)
        .subscribe(chart => {
          this.chart = chart;
          this.currentVersion = params['version'] || this.chart.relationships.latestChartVersion.data.version;
          this.titleVersion = params['version'] || '';
          this.updateMetaTags();
        });
    });
  }

  /**
   * Content for the title version tag
   *
   * @return {string} Title to display in the site
   */
  contentTitleVersion(): string {
    if (this.titleVersion.length > 0) {
      return `${this.chart.attributes.name} ${this.titleVersion}`;
    } else {
      return this.chart.attributes.name;
    }
  }

  /**
   * Update the metatags with the name and the description of the application.
   */
  updateMetaTags(): void {
    let title: string = this.contentTitleVersion();
    this.metaService.setTitle(title);
    this.metaService.setTag('description', this.chart.attributes.description);
    this.metaService.setTag('og:title', title);
    this.metaService.setTag('og:description', this.chart.attributes.description);
  }
}

{'fraction_non_alphanumeric': 0.1318319143092557, 'fraction_numerical': 0.0008239494644328481, 'mean_word_length': 3.541147132169576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '7554910', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1022, 'n_words': 240}