<commit_before>import { Component, ElementRef, ViewChild } from '@angular/core'
import { Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models'
import { LiveVideoService } from './live-video.service'

@Component({
  selector: 'my-live-stream-information',
  templateUrl: './live-stream-information.component.html',
  styleUrls: [ './live-stream-information.component.scss' ]
})
export class LiveStreamInformationComponent {
  @ViewChild('modal', { static: true }) modal: ElementRef

  video: Video
  live: LiveVideo
  latestLiveSessions: LiveVideoSession[] = []

  constructor (
    private modalService: NgbModal,
    private liveVideoService: LiveVideoService
  ) { }

  show (video: Video) {
    this.video = video
    this.live = undefined

    this.loadLiveInfo(video)

    this.modalService
      .open(this.modal, { centered: true })
  }

  getVideoUrl (video: { shortUUID: string }) {
    return Video.buildWatchUrl(video)
  }

  getErrorLabel (session: LiveVideoSession) {
    if (!session.error) return undefined

    const errors: { [ id in LiveVideoError ]: string } = {
      [LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`,
      [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`,
      [LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`,
      [LiveVideoError.FFMPEG_ERROR]: $localize`Server error`,
      [LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded`
    }

    return errors[session.error]
  }

  private loadLiveInfo (video: Video) {
    this.liveVideoService.getVideoLive(video.id)
      .subscribe(live => this.live = live)

    this.liveVideoService.listSessions(video.id)
      .subscribe(({ data }) => this.latestLiveSessions = data.slice(0, 5))
  }
}<commit_msg>Fix latest live sessions order<commit_after>import { Component, ElementRef, ViewChild } from '@angular/core'
import { Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models'
import { LiveVideoService } from './live-video.service'

@Component({
  selector: 'my-live-stream-information',
  templateUrl: './live-stream-information.component.html',
  styleUrls: [ './live-stream-information.component.scss' ]
})
export class LiveStreamInformationComponent {
  @ViewChild('modal', { static: true }) modal: ElementRef

  video: Video
  live: LiveVideo
  latestLiveSessions: LiveVideoSession[] = []

  constructor (
    private modalService: NgbModal,
    private liveVideoService: LiveVideoService
  ) { }

  show (video: Video) {
    this.video = video
    this.live = undefined

    this.loadLiveInfo(video)

    this.modalService
      .open(this.modal, { centered: true })
  }

  getVideoUrl (video: { shortUUID: string }) {
    return Video.buildWatchUrl(video)
  }

  getErrorLabel (session: LiveVideoSession) {
    if (!session.error) return undefined

    const errors: { [ id in LiveVideoError ]: string } = {
      [LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`,
      [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`,
      [LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`,
      [LiveVideoError.FFMPEG_ERROR]: $localize`Server error`,
      [LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded`
    }

    return errors[session.error]
  }

  private loadLiveInfo (video: Video) {
    this.liveVideoService.getVideoLive(video.id)
      .subscribe(live => this.live = live)

    this.liveVideoService.listSessions(video.id)
      .subscribe(({ data }) => this.latestLiveSessions = data.reverse().slice(0, 5))
  }
}
{'fraction_non_alphanumeric': 0.12496655070912496, 'fraction_numerical': 0.0010703773080010704, 'mean_word_length': 4.120547945205479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3318620', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1131, 'n_words': 236}