Skip to content

Mpro coleta#5

Open
thyagopereira wants to merge 5 commits intomainfrom
mpro_coleta
Open

Mpro coleta#5
thyagopereira wants to merge 5 commits intomainfrom
mpro_coleta

Conversation

@thyagopereira
Copy link
Contributor

  • Criação do file só acontece com sudo, trabalhando nisso.
  • Avanços estruturais, e de coleta. Me atrasou um pouco a necessidade de lidar com o id de sessão.

crawler.go Outdated
page, err := ioutil.ReadAll(resp.Body)
htmlCode := string(page)

id := strings.Split(htmlCode, "Constants.viewingSessionId = \"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poderia, por favor, fazer um teste de unidade para essa função? para tornar o teste mais fácil, pode utilizar a bilioteca httptest

Copy link
Contributor

@danielfireman danielfireman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estamos quase chegando lá! 😄


// Retorna as url para download de cada planilha em questão
func requestURL(year, month int) (urlRequests, error) {
remuIDURL := fmt.Sprint("https://servicos-portal.mpro.mp.br/plcVis/frameset?__report=..%2FROOT%2Frel%2Fcontracheque%2Fmembros%2FremuneracaoMembrosAtivos.rptdesign&anomes=", year, fmt.Sprintf("%02d", month), "&nome=&cargo=&lotacao=")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aplicar o mesmo estilo da sugestão abaixo aqui.

Copy link
Contributor

@danielfireman danielfireman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bacana! Favor endereçar os comentários abaixo antes de fazer merge

}
defer resp.Body.Close()

_, err = os.Stat(outputPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colocar esse assinalamento no if abaixo

var fileName = fmt.Sprintf("%d_%02d_remu.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)

err = download(request.remunerationURL, filePath, outputPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colocar esse assinalamento no if abaixo

var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)

err = download(request.benefitsURL, filePath, outputPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mover assinalamento para dentro do if abaixo

Month int `envconfig:"MONTH" required:"true"`
Year int `envconfig:"YEAR" required:"true"`
OutputFolder string `envconfig:"OUTPUT_FOLDER" default:"/output"`
OutputFolder string `envconfig:"OUTPUT_FOLDER" default:"./output"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remover "."

fileNames := Crawl(month, year, outputPath)
fileNames, err := Crawl(month, year, outputPath)
if err != nil {
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usar pacote status


paths = append(paths, filePath)
case viURLType:
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
fileName := fmt.Sprintf("%d_%02d_vi.xls", year, month)

paths = append(paths, filePath)
case viURLType:
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var filePath = fmt.Sprint(outputPath, "/", fileName)
filePath := fmt.Sprint(outputPath, "/", fileName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usar filepath.Join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants