<commit_before>import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';

import { ProgramService } from './program.service';
import { Program, ProgramSchedule, ProgramStage, ProgramScheduleType } from './program';

import { ZoneService } from './../zones/zone.service';
import { Zone } from './../zones/zone';

class ProgramScheduleViewModel {

  startTime: Date;

  public constructor(
    public model: ProgramSchedule) {

    this.startTime = new Date();
    this.startTime.setHours(model.startTimeHours);
    this.startTime.setMinutes(model.startTimeMinutes);
  }

  startTimeChanged(): void {
    this.model.startTimeHours = this.startTime.getHours();
    this.model.startTimeMinutes = this.startTime.getMinutes();
  }
}

@Component({
  selector: 'my-program-detail',
  templateUrl: 'app/programs/program-detail.component.html'
})
export class ProgramDetailComponent implements OnInit {
  
  program: Program;
  orderedStages: ProgramStage[];
  schedules: ProgramScheduleViewModel[];
  
  zones: Zone[];
  
  programScheduleTypes = [
    { display: 'All Days', value: ProgramScheduleType.AllDays },
    { display: 'Odd Days', value: ProgramScheduleType.OddDays },
    { display: 'Even Days', value: ProgramScheduleType.EvenDays }
  ];
  
  constructor(
    private router: Router,
    private route: ActivatedRoute,
    private programService: ProgramService,
    private zoneService: ZoneService) {
  }
  
  ngOnInit(): void {
    
    this.route.params.forEach((params: Params) => {

      let programId = Number.parseInt(params['id']);

      this.zoneService.getZones()
        .then(zones => this.zones = zones)
        .then(() => {
          if (programId) {
            return this.programService
              .getProgram(programId)
              .then(program => {
                this.program = program;
              });
          } else {
            let newProgram = new Program();
            newProgram.programId = 0;
            newProgram.name = "New Program";
            this.program = newProgram;
          }
        })
        .then(() => {
          this.schedules = this.program.schedules
            .map(schedule => new ProgramScheduleViewModel(schedule));
        })
        .then(() => {
          this.orderedStages = this.program.stages
            .sort((a, b) => b.orderId - a.orderId);
        });
    });
  }
<commit_msg>Fix bug where stage ordering is reversed<commit_after>import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';

import { ProgramService } from './program.service';
import { Program, ProgramSchedule, ProgramStage, ProgramScheduleType } from './program';

import { ZoneService } from './../zones/zone.service';
import { Zone } from './../zones/zone';

class ProgramScheduleViewModel {

  startTime: Date;

  public constructor(
    public model: ProgramSchedule) {

    this.startTime = new Date();
    this.startTime.setHours(model.startTimeHours);
    this.startTime.setMinutes(model.startTimeMinutes);
  }

  startTimeChanged(): void {
    this.model.startTimeHours = this.startTime.getHours();
    this.model.startTimeMinutes = this.startTime.getMinutes();
  }
}

@Component({
  selector: 'my-program-detail',
  templateUrl: 'app/programs/program-detail.component.html'
})
export class ProgramDetailComponent implements OnInit {
  
  program: Program;
  orderedStages: ProgramStage[];
  schedules: ProgramScheduleViewModel[];
  
  zones: Zone[];
  
  programScheduleTypes = [
    { display: 'All Days', value: ProgramScheduleType.AllDays },
    { display: 'Odd Days', value: ProgramScheduleType.OddDays },
    { display: 'Even Days', value: ProgramScheduleType.EvenDays }
  ];
  
  constructor(
    private router: Router,
    private route: ActivatedRoute,
    private programService: ProgramService,
    private zoneService: ZoneService) {
  }
  
  ngOnInit(): void {
    
    this.route.params.forEach((params: Params) => {

      let programId = Number.parseInt(params['id']);

      this.zoneService.getZones()
        .then(zones => this.zones = zones)
        .then(() => {
          if (programId) {
            return this.programService
              .getProgram(programId)
              .then(program => {
                this.program = program;
              });
          } else {
            let newProgram = new Program();
            newProgram.programId = 0;
            newProgram.name = "New Program";
            this.program = newProgram;
          }
        })
        .then(() => {
          this.schedules = this.program.schedules
            .map(schedule => new ProgramScheduleViewModel(schedule));
        })
        .then(() => {
          this.orderedStages = this.program.stages
            .sort((a, b) => a.orderId - b.orderId);
        });
    });
  }

{'fraction_non_alphanumeric': 0.12862132730634887, 'fraction_numerical': 0.0004109307581672488, 'mean_word_length': 2.6247207743857035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '5817904', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1382, 'n_words': 290}