Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Commit 49351d3

Browse files
committed
fix coverage endpoint
1 parent 8fb3179 commit 49351d3

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type config struct {
4747
// should be true in production
4848
TLS bool
4949

50+
// Weather or not to run cron updates
51+
RunCron bool
52+
5053
// setting HTTP_AUTH_USERNAME & HTTP_AUTH_PASSWORD
5154
// will enable basic http auth for the server. This is a single
5255
// username & password that must be passed in with every request.

coverage/coverage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package coverage
22

33
import (
4+
"fmt"
45
"github.com/archivers-space/archive"
56
"github.com/archivers-space/coverage/repositories"
67
"github.com/archivers-space/coverage/tree"
@@ -133,6 +134,8 @@ func (c CoverageGenerator) Tree() (*tree.Node, error) {
133134
// t.Id = c.Sources[0].Id
134135
// }
135136

137+
fmt.Println(c.Repos)
138+
136139
for _, s := range c.Repos {
137140
if err := s.AddUrls(t, c.Sources...); err != nil {
138141
// log.Info(s.Info()["Name"])

coverage/coverage_requests.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func (CoverageRequests) Tree(p *CoverageTreeParams, res *tree.Node) error {
4040
u.Scheme = "http"
4141
}
4242

43-
// node = node.Child(u.Scheme).Child(u.Host)
4443
root = root.Child(fmt.Sprintf("%s://%s", u.Scheme, u.Host))
4544
components := strings.Split(u.Path, "/")
4645
for _, c := range components {

cron.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ func cron() (stop chan (bool)) {
2929
}
3030

3131
func update(db *sql.DB) error {
32-
lastUpdate = time.Now()
33-
log.Info("updating:", lastUpdate)
32+
if cfg.RunCron {
33+
lastUpdate = time.Now()
34+
log.Info("updating:", lastUpdate)
3435

35-
if err := calcSourceCoverage(db); err != nil {
36-
return err
37-
}
36+
if err := calcSourceCoverage(db); err != nil {
37+
return err
38+
}
3839

39-
if err := calcPrimerSourceCoverage(db); err != nil {
40-
return err
40+
if err := calcPrimerSourceCoverage(db); err != nil {
41+
return err
42+
}
4143
}
4244

4345
return nil

0 commit comments

Comments
 (0)