Compare commits
	
		
			3 Commits
		
	
	
		
			e15992e865
			...
			28995790cc
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 28995790cc | |||
| 90bec49826 | |||
| 52732d2ae1 | 
| @ -5,7 +5,7 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Version Constants | // Version Constants | ||||||
| const versionNum string = "2024.10.1" | const versionNum string = "2024.10.2" | ||||||
| const versionSuffix string = "" | const versionSuffix string = "" | ||||||
| const Version string = versionNum + versionSuffix | const Version string = versionNum + versionSuffix | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							| @ -16,6 +16,7 @@ import ( | |||||||
| 	"git.fjla.uk/owlboard/timetable-mgr/helpers" | 	"git.fjla.uk/owlboard/timetable-mgr/helpers" | ||||||
| 	"git.fjla.uk/owlboard/timetable-mgr/log" | 	"git.fjla.uk/owlboard/timetable-mgr/log" | ||||||
| 	"git.fjla.uk/owlboard/timetable-mgr/messaging" | 	"git.fjla.uk/owlboard/timetable-mgr/messaging" | ||||||
|  | 	"git.fjla.uk/owlboard/timetable-mgr/pis" | ||||||
| 	"git.fjla.uk/owlboard/timetable-mgr/stations" | 	"git.fjla.uk/owlboard/timetable-mgr/stations" | ||||||
| 	"git.fjla.uk/owlboard/timetable-mgr/vstp" | 	"git.fjla.uk/owlboard/timetable-mgr/vstp" | ||||||
| 	"go.uber.org/zap" | 	"go.uber.org/zap" | ||||||
| @ -66,6 +67,7 @@ func main() { | |||||||
| 	go cif.CheckCif(cfg) | 	go cif.CheckCif(cfg) | ||||||
| 	go corpus.CheckCorpus(cfg) | 	go corpus.CheckCorpus(cfg) | ||||||
| 	go stations.Check() | 	go stations.Check() | ||||||
|  | 	go pis.Check() | ||||||
| 
 | 
 | ||||||
| 	if cfg.VstpOn { | 	if cfg.VstpOn { | ||||||
| 		messaging.StompInit(cfg) | 		messaging.StompInit(cfg) | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								pis/data.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								pis/data.go
									
									
									
									
									
								
							| @ -14,21 +14,27 @@ import ( | |||||||
| 
 | 
 | ||||||
| // Process the YAML data to a struct | // Process the YAML data to a struct | ||||||
| func processYaml(yamlStr string) (*[]database.PIS, error) { | func processYaml(yamlStr string) (*[]database.PIS, error) { | ||||||
| 	var pis []PisData | 	// Define 'container' struct | ||||||
|  | 	var pisData struct { | ||||||
|  | 		Pis []PisData `yaml:"pis"` | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	// Unmarshal the YAML data into a slice of PisData | 	// Unmarshal the YAML data into the structure | ||||||
| 	err := yaml.Unmarshal([]byte(yamlStr), &pis) | 	err := yaml.Unmarshal([]byte(yamlStr), &pisData) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, fmt.Errorf("failed to unmarshal YAML: %v", err) | 		return nil, fmt.Errorf("failed to unmarshal YAML: %v", err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Perform deduplication on the entire pis slice | 	// Perform deduplication on the entire pis slice | ||||||
| 	err = deduplicateCodes(&pis) | 	err = deduplicateCodes(&pisData.Pis) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	documents, err := convertPisForDatabase(&pis) | 	documents, err := convertPisForDatabase(&pisData.Pis) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	return documents, nil | 	return documents, nil | ||||||
| } | } | ||||||
|  | |||||||
| @ -9,6 +9,9 @@ import ( | |||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
|  | 
 | ||||||
|  | 	"git.fjla.uk/owlboard/timetable-mgr/log" | ||||||
|  | 	"go.uber.org/zap" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| @ -127,7 +130,7 @@ func extractFiles(gzipStream io.Reader, dest string) error { | |||||||
| 			} | 			} | ||||||
| 			outFile.Close() | 			outFile.Close() | ||||||
| 		default: | 		default: | ||||||
| 			fmt.Printf("Unable to handle filetype %c in %s\n", header.Typeflag, header.Name) | 			log.Warn("Unable to handle filetype", zap.String("Typeflag", string(header.Typeflag)), zap.String("Filename", header.Name)) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| @ -145,7 +148,7 @@ func extractYamlData(dir string) (string, error) { | |||||||
| 		// Check if the path contains 'pis' and has a .yaml or .yml extension | 		// Check if the path contains 'pis' and has a .yaml or .yml extension | ||||||
| 		if strings.Contains(path, "/pis/") && !info.IsDir() && | 		if strings.Contains(path, "/pis/") && !info.IsDir() && | ||||||
| 			(strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) { | 			(strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) { | ||||||
| 			fmt.Printf("Processing YAML file in 'pis' directory: %s\n", path) | 			log.Debug("Processing YAML", zap.String("directory", path)) | ||||||
| 
 | 
 | ||||||
| 			file, err := os.Open(path) | 			file, err := os.Open(path) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| @ -179,7 +182,7 @@ func cleanupFiles(paths ...string) { | |||||||
| 	for _, path := range paths { | 	for _, path := range paths { | ||||||
| 		err := os.RemoveAll(path) | 		err := os.RemoveAll(path) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			fmt.Printf("Error removing %s: %v\n", path, err) | 			log.Warn("Error removing file", zap.String("path", path), zap.Error(err)) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -48,7 +48,7 @@ func Subscribe() { | |||||||
| 						log.Error("VSTP Message Error", zap.Error(msg.Err)) | 						log.Error("VSTP Message Error", zap.Error(msg.Err)) | ||||||
| 					} else { | 					} else { | ||||||
| 						if msg != nil { | 						if msg != nil { | ||||||
| 							log.Info("VSTP Message Received") | 							log.Debug("VSTP Message Received") | ||||||
| 							handle(msg) | 							handle(msg) | ||||||
| 						} else { | 						} else { | ||||||
| 							log.Info("VSTP Message Empty") | 							log.Info("VSTP Message Empty") | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user