Skip to content

Commit 9100aa7

Browse files
committed
Clean cruft and fix JSON indents for #97
1 parent ec7c82e commit 9100aa7

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

main.go

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,6 @@ func generateSummary(urir string, basetm *list.List, format string, dataCh chan
338338
start := time.Now()
339339
defer benchmarker("AGGREGATOR", "serialize", fmt.Sprintf("%d mementos serialized", basetm.Len()), start, sess)
340340
defer close(dataCh)
341-
342-
dataCh <- fmt.Sprintf("{\n"+` "original_uri": "%s",`+"\n", urir)
343-
//dataCh <- fmt.Sprintf(`!keys ["memento_datetime_YYYYMMDDhhmmss"]` + "\n")
344-
//dataCh <- fmt.Sprintf(`!meta {"original_uri": "%s"}`+"\n", urir)
345-
//dataCh <- fmt.Sprintf(`!meta {"timegate_uri": "%s/timegate/%s"}`+"\n", *proxy, urir)
346-
// dataCh <- fmt.Sprintf(`!meta {"timemap_uri": {"link_format": "%s/timemap/link/%s", "json_format": "%s/timemap/json/%s", "cdxj_format": "%s/timemap/cdxj/%s"}}`+"\n", *proxy, urir, *proxy, urir, *proxy, urir)
347-
348341
i := 0
349342
type Memento struct {
350343
Urim string
@@ -367,8 +360,6 @@ func generateSummary(urir string, basetm *list.List, format string, dataCh chan
367360
rels = strings.Join(lnk.NavRels, " ") + " " + rels
368361
}
369362
i += 1
370-
dataCh <- fmt.Sprintf(`%d`+"\n", i)
371-
372363
// NOTE that the temporally first for an archive is likely not the first memento in the whole TimeMap
373364
hostbuck := strings.SplitN(lnk.Href, "/", 4)
374365
archive, exists := archives[hostbuck[2]]
@@ -397,28 +388,26 @@ func generateSummary(urir string, basetm *list.List, format string, dataCh chan
397388
newarchive := Archive{memento, memento, 1}
398389
archives[hostbuck[2]] = newarchive
399390
}
400-
dataCh <- fmt.Sprintf(`%s %s`+"\n", lnk.Timeobj.Format(time.RFC3339), lnk.Href)
401-
//dataCh <- fmt.Sprintf(`%s {"uri": "%s", "rel": "%s", "datetime": "%s"}`+"\n", lnk.Timestr, lnk.Href, rels, lnk.Datetime)
402391
}
392+
dataCh <- fmt.Sprintf("{\n"+` "original_uri": "%s",`+"\n", urir)
403393
// Count total mementos in all archives
404394
mcount := 0
405-
dataCh <- fmt.Sprintf(`"archives": {` + "\n")
395+
dataCh <- fmt.Sprintf(` "archives": {` + "\n")
406396
for host, archive := range archives {
407397
mcount += archive.Count
408-
dataCh <- fmt.Sprintf(` "%s":{`+"\n", host)
409-
dataCh <- fmt.Sprintf(` "count": %d,"`+"\n", archive.Count)
410-
dataCh <- fmt.Sprintf(` "first":{` + "\n")
411-
dataCh <- fmt.Sprintf(` "datetime": %d,`+"\n", archive.First.Datetime)
412-
dataCh <- fmt.Sprintf(` "uri": "%s",`+"\n }\n", archive.First.Urim)
413-
dataCh <- fmt.Sprintf(` "last":{` + "\n")
414-
dataCh <- fmt.Sprintf(` "datetime": %d,`+"\n", archive.Last.Datetime)
415-
dataCh <- fmt.Sprintf(` "uri": "%s",`+"\n }\n", archive.Last.Urim)
398+
dataCh <- fmt.Sprintf(` "%s":{`+"\n", host)
399+
dataCh <- fmt.Sprintf(` "count": %d,"`+"\n", archive.Count)
400+
dataCh <- fmt.Sprintf(` "first":{` + "\n")
401+
dataCh <- fmt.Sprintf(` "datetime": %d,`+"\n", archive.First.Datetime)
402+
dataCh <- fmt.Sprintf(` "uri": "%s",`+"\n }\n", archive.First.Urim)
403+
dataCh <- fmt.Sprintf(` "last":{` + "\n")
404+
dataCh <- fmt.Sprintf(` "datetime": %d,`+"\n", archive.Last.Datetime)
405+
dataCh <- fmt.Sprintf(` "uri": "%s",`+"\n }\n", archive.Last.Urim)
416406
dataCh <- fmt.Sprintf(" },\n")
417407
}
418-
dataCh <- fmt.Sprintf(`"total_mementos": %d`, mcount)
419-
fmt.Printf("Total memento count: %d\n", mcount)
408+
dataCh <- fmt.Sprintf(` "total_mementos": %d`+"\n", mcount)
409+
// Echo out server-side for debugging
420410
fmt.Println(archives)
421-
422411
}
423412

424413
func serializeLinks(urir string, basetm *list.List, format string, dataCh chan string, navonly bool, sess *Session) {

0 commit comments

Comments
 (0)