示例#1
0
//handle takes a job and appropriate sends it to a function that will run it
func (qs *QueueService) handle(job *QueueJob) {
	switch job.Job {
	case "updateDatasetFile":
		udfjd := UpdateDatasetFileJobData{}
		jobJson, err := json.Marshal(job.Data)
		if err != nil {
			log.Fatal("Error creating JSON: ", err)
		}

		err = json.Unmarshal(jobJson, &udfjd)
		if err != nil {
			log.Fatal("Error parsing JSON: ", err)
		}
		/*
			pds := NewPredictDatasetService(database.GetDatabase())
			pds.UpdateFile(udfjd)
		*/
		fs := files.NewFileService(database.GetDatabase())
		newTrans, err := fs.UpdateFile(udfjd.Extra.Subdom, udfjd.FileGUID, udfjd.TemplateGUID)
		//Alert luminous that its Done
		queue := NewQueueService("luminous")
		jobData := structs.Map(udfjd)
		jobData["NewTrans"] = newTrans
		qj := &QueueJob{
			Job:  `Spark451\Luminous\v2\Predict\Classes\Datasets@finishDatasetCreation`,
			Data: jobData,
		}
		queue.Push(qj)
	}
}
示例#2
0
func (ec *ExportController) Export(w http.ResponseWriter, r *http.Request) ([]byte, error) {
	vars := mux.Vars(r)
	fileGUID := vars["fileGUID"]
	templateGUID := vars["templateGUID"]

	fs := files.NewFileService(database.GetDatabase())
	fileObj, err := fs.GetFile(fileGUID)

	ts := templates.NewTemplateService(database.GetDatabase())
	templateObj, err := ts.GetTemplate(templateGUID)

	var result []string
	switch fileObj.Extension {
	case "csv":
		{
			fileName, _ := fileObj.DownloadFromUrl("storage")
			csv := csv.NewCSVService(fileName, true)
			for _, field := range templateObj.Fields {
				col := csv.GetColumn(field.Field)
				result = transformations.ApplyTransformations(col, field.Transformations)
				fmt.Println(result)
			}
		}
	}

	//tj,_ := json.Marshal(t)
	fj, _ := json.Marshal(fileObj)
	return fj, err
}
示例#3
0
func (ac AnalyticsController) GetPivotTables(w http.ResponseWriter, r *http.Request) ([]byte, error) {
	vars := mux.Vars(r)
	fileGUID := vars["fileGUID"]
	//templateGUID := vars["templateGUID"]

	//ts := services.NewTemplateService(database.GetDatabase())
	//t := ts.GetTemplate(templateGUID)

	fs := files.NewFileService(database.GetDatabase())
	fileObj, err := fs.GetFile(fileGUID)

	if fileObj.Extension == "csv" {
		fileName, _ := fileObj.DownloadFromUrl("storage")
		csv := csvElement.NewCSVService(fileName, true)
		fmt.Println(csv)

		//os.Remove(fileName)
	}

	//tj,_ := json.Marshal(t)
	fj, _ := json.Marshal(fileObj)
	return fj, err
}