Skip to content

Commit 068f8ec

Browse files
committed
func fetchDocument modification
1 parent 415e175 commit 068f8ec

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

backend/internal/excel_adapter/excel_adapter.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package excel_adapter
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"os"
6-
"path/filepath"
77
"strings"
88

99
"github.com/fatih/color"
1010

11-
ade_linter "github.com/HyperloopUPV-H8/ade-linter"
1211
"github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/internals"
1312
internalModels "github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/internals/models"
1413
"github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/models"
1514
trace "github.com/rs/zerolog/log"
16-
"github.com/xuri/excelize/v2"
1715
)
1816

1917
type ExcelAdapterConfig struct {
@@ -63,24 +61,18 @@ func (adapter ExcelAdapter) GetGlobalInfo() models.GlobalInfo {
6361
func fetchDocument(downloadConfig internals.DownloadConfig, parseConfig internals.ParseConfig) internalModels.Document {
6462
trace.Info().Str("id", downloadConfig.Id).Str("path", downloadConfig.Path).Str("name", downloadConfig.Name).Msg("fetch document")
6563

66-
errDownloading := internals.DownloadFile(downloadConfig)
67-
if errDownloading != nil {
68-
trace.Error().Stack().Err(errDownloading).Msg("")
69-
trace.Warn().Str("id", downloadConfig.Id).Str("path", downloadConfig.Path).Str("name", downloadConfig.Name).Msg("using local document")
70-
}
71-
72-
file, err := excelize.OpenFile(filepath.Join(downloadConfig.Path, downloadConfig.Name))
64+
file, err := os.Open(downloadConfig.Path)
7365
if err != nil {
74-
trace.Fatal().Stack().Err(err).Msg("")
66+
trace.Fatal().Stack().Err(err).Msg("Error abriendo el archivo JSON")
7567
}
68+
defer file.Close()
7669

77-
if !ade_linter.Lint(file) {
78-
if !promptContinue() {
79-
os.Exit(1)
80-
}
70+
var document internalModels.Document
71+
if err := json.NewDecoder(file).Decode(&document); err != nil {
72+
trace.Fatal().Stack().Err(err).Msg("Error decodificando JSON")
8173
}
8274

83-
return internals.GetDocument(file, parseConfig)
75+
return document
8476
}
8577

8678
func promptContinue() bool {

0 commit comments

Comments
 (0)