Skip to content
Snippets Groups Projects
Commit 1994b158 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Start adding pagination again.

parent 1636ecca
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package fetch ...@@ -3,6 +3,7 @@ package fetch
import ( import (
"fmt" "fmt"
"log" "log"
"math"
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
...@@ -51,7 +52,7 @@ func Init(pw string) { ...@@ -51,7 +52,7 @@ func Init(pw string) {
var m2 PuppetclassMessage var m2 PuppetclassMessage
fff("puppetclasses", &m2) fff_pages("puppetclasses", &m2)
for group, entries := range m2.Results { for group, entries := range m2.Results {
log.Print("Handling ", group) log.Print("Handling ", group)
...@@ -90,11 +91,19 @@ func fff (url string, message interface{}) { ...@@ -90,11 +91,19 @@ func fff (url string, message interface{}) {
func fff_pages(url string, message IsMessage) { func fff_pages(url string, message IsMessage) {
fff(url, &message) fff(url, &message)
log.Printf("message = %+v", message.GetMessage()) log.Printf("message = %+v", message.GetMessage())
// TODO
// logic here for fetching additional pages m := message.GetMessage()
// (preferably async) pagecount := int(math.Ceil(m.Total / m.Per_page))
// IsMessage should require a Merge method for i := 2; i < pagecount; i++ {
// TODO also figure out pointer stuff // TODO this kind of works for dictionaries, since json.Unmarshal
// reuses an existing dictionary. I believe that it however
// "fails" if the same key is present in multiple responses, and
// that it doesn't work for list responses.
// TODO also, all these should run in paralell
fff(url + fmt.Sprintf("?page=%d", i),
&message)
log.Printf("message = %+v", message.GetMessage())
}
} }
func GetClassList(host HostRecord) []string { func GetClassList(host HostRecord) []string {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment