Exemplo n.º 1
0
func (analyser Analyser) processModules() {

	institutions := repository.GetAllInstitutions()
	subjects := education.GetAllSubjects()

	for _, institution := range institutions {
		analyser.CreateInstitutionAnalyser(institution)
	}

	for _, subject := range subjects {
		analyser.CreateSubjectAnalyser(subject)
	}

	analyser.Finish()
}
Exemplo n.º 2
0
func (analyser *InstitutionAnalyser) perform() {

	institution := analyser.institution

	subjects := education.GetAllSubjects()

	for _, subject := range subjects {
		exists := false
		programs := institution.GetProgramsBySubjectID(subject.GetID())

		keywords := word.NewDigester("")
		formats := word.NewDigester("")
		description := word.NewDigester("")

		for _, program := range programs {
			exists = true
			fieldList := "`description`, `formats`, `keywords`"
			sql := "SELECT " + fieldList + " FROM `digest_program` WHERE program=? AND analyse=? "
			rows, _ := database.Connection.Query(sql, program.GetID(), analyser.parent.id)
			for rows.Next() {
				var s1, s2, s3 string
				rows.Scan(&s1, &s2, &s3)
				description = description.Combine(word.NewDigesterFromJSON(s1))
				formats = formats.Combine(word.NewDigesterFromJSON(s2))
				keywords = keywords.Combine(word.NewDigesterFromJSON(s3))
			}
		}
		if exists {
			keywords.SortByCounter("DESC")
			description.SortByCounter("DESC")
			formats.SortByCounter("DESC")

			columns := "`institution`, `subject`, `description`, `formats`, `keywords`, `analyse`"
			table := "digest_institution"

			buffer := database.NewSQLBuffer(table, columns)
			buffer.AddRow(institution.ID, subject.GetID(), description.GetPlainJSON(), formats.GetPlainJSON(), keywords.GetPlainJSON(), analyser.parent.id)

			err := buffer.Exec()

			if err != nil {
				fmt.Println(err)
			}
		}
	}
}
Exemplo n.º 3
0
func (controller *Controller) loadPrograms() {
	controller.Data["subjects"] = education.GetAllSubjects()
}