package api

import (
	"encoding/json"
	"fmt"
	"net/http"

	// "../schedule"
	// "../settings"
)

const (
	INDATA = "input/"
)

func Generate(w http.ResponseWriter, r *http.Request) {
	showAPIRequest(r)
	if r.Method == "GET" {
		// var result [][]*schedule.Schedule
		// var generator = schedule.NewGenerator(&schedule.Generator{
		// 	Day: schedule.MONDAY,
		// 	// NumTables: 11,
		// 	Groups:   schedule.ReadGroups(INDATA + "groups.json"),
		// 	Teachers: schedule.ReadTeachers(INDATA + "teachers.json"),
		// })
		// for iter := 1; iter <= 7; iter++ {
		// 	midResult := generator.Generate(nil)
		// 	result = append(result, midResult)
		// 	var group Group
		// 	settings.DB.Where("groupnumber = ?", midResult.Group).First(&group)
		// 	var schedule Schedule
		// 	schedule.IsShort = false
		// 	schedule.IsEvenWeek = false
		// 	schedule.Weekday = midResult.Day
		// 	schedule.IDGroup = group.ID
		// 	settings.DB.Create(&schedule)
		// 	for i, row := range schedule.Row{
		// 		if schedule.Row != nil {
		// 			var schOfGroup Scheduleofgroup
		// 			var subject Subject
		// 			settings.DB.Where("shortname = ?", row.Subject[1]).First(&subject)
		// 			schOfGroup.IDSubject = subject.ID
		// 			schOfGroup.IDGroup = group.ID
		// 			var sch Schedule
		// 			settings.DB.Where(&schedule).First(&schedule)
		// 			schOfGroup.IDSchedule = sch.ID
		// 			schOfGroup.Lessonnumber = i

		// 			var classroom Classroom
		// 			settings.DB.Where("name = ?", row.Cabinet[1]).First(&classroom)

		// 			schOfGroup.IDClassroom = classroom.ID
		// 		}
		// 	}
		// }
		// json.NewEncoder(w).Encode(result)
	}
}

func printJSON(data interface{}) {
	jsonData, _ := json.MarshalIndent(data, "", "\t")
	fmt.Println(string(jsonData))
}
