<commit_before>import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { SubscriptionLike } from 'rxjs/internal/types';
import * as firebase from 'firebase/app';
import { SnippetService } from '../../shared/services/snippet.service';

function getTagsStringList(tagsArray: Array<string>): string {
  let tagsStringList = '';
  tagsArray.forEach(x => {
    tagsStringList += `- ${x}\n`;
  });
  tagsStringList += `\n`;
  return tagsStringList;
}

function getSnippet(value): string {

  const result: Array<string> = [];

  result.push(`
---
title: ${value.title}

author: ${value.author || `*your github username will be added*`}

level: ${value.level}

tags:
${getTagsStringList(value.tags)}
---`);

  result.push(`
# Content
${value.content}`);

  if (value.bonus) {
    result.push(`
# Bonus
${value.bonus}`);
  }

  if (value.links) {
    result.push(`
# Links
${value.links}`
    );
  }

  if (value.demo['app.component.ts']) {
    result.push(`
# ComponentCode
\`\`\`typescript
${value.demo['app.component.ts']}
\`\`\``);
  }

  if (value.demo['app.module.ts']) {
    result.push(`
# ModuleCode
\`\`\`typescript
${value.demo['app.module.ts']}
\`\`\``);
  }

  if (value.demo['main.ts']) {
    result.push(`
# MainCode
\`\`\`typescript
${value.demo['main.ts']}
\`\`\``);
  }

  result.push(`---`);

  return result.join(`\n`);
}


@Component({
  selector: 'codelab-snippet-overview',
  templateUrl: './snippet-overview.component.html',
  styleUrls: ['./snippet-overview.component.scss']
})
export class SnippetOverviewComponent implements OnInit, OnDestroy {

  githubAuth;
  createPRSubscription: SubscriptionLike;
  isPRCreating = false;

  snippet: string;

  constructor(
    private afAuth: AngularFireAuth,
    private snippetService: SnippetService,
    public dialogRef: MatDialogRef<SnippetOverviewComponent>,
    @Inject(MAT_DIALOG_DATA) public data: object
  ) {
  }
<commit_msg>Fix - improved tags function in snippet modal<commit_after>import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { SubscriptionLike } from 'rxjs/internal/types';
import * as firebase from 'firebase/app';
import { SnippetService } from '../../shared/services/snippet.service';

function getTagsStringList(tagsArray: Array<string>): string {
  return tagsArray.map(x => `- ${x}`).join(`\n`);
}

function getSnippet(value): string {

  const result: Array<string> = [];

  result.push(`
---
title: ${value.title}

author: ${value.author || `*your github username will be added*`}

level: ${value.level}

tags:
${getTagsStringList(value.tags)}

---`);

  result.push(`
# Content
${value.content}`);

  if (value.bonus) {
    result.push(`
# Bonus
${value.bonus}`);
  }

  if (value.links) {
    result.push(`
# Links
${value.links}`
    );
  }

  if (value.demo['app.component.ts']) {
    result.push(`
# ComponentCode
\`\`\`typescript
${value.demo['app.component.ts']}
\`\`\``);
  }

  if (value.demo['app.module.ts']) {
    result.push(`
# ModuleCode
\`\`\`typescript
${value.demo['app.module.ts']}
\`\`\``);
  }

  if (value.demo['main.ts']) {
    result.push(`
# MainCode
\`\`\`typescript
${value.demo['main.ts']}
\`\`\``);
  }

  return result.join(`\n`);
}


@Component({
  selector: 'codelab-snippet-overview',
  templateUrl: './snippet-overview.component.html',
  styleUrls: ['./snippet-overview.component.scss']
})
export class SnippetOverviewComponent implements OnInit, OnDestroy {

  githubAuth;
  createPRSubscription: SubscriptionLike;
  isPRCreating = false;

  snippet: string;

  constructor(
    private afAuth: AngularFireAuth,
    private snippetService: SnippetService,
    public dialogRef: MatDialogRef<SnippetOverviewComponent>,
    @Inject(MAT_DIALOG_DATA) public data: object
  ) {
  }

{'fraction_non_alphanumeric': 0.18375532714966156, 'fraction_numerical': 0.0, 'mean_word_length': 4.089285714285714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6278500', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1383, 'n_words': 261}