OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "encoding/json" | 4 "encoding/json" |
5 "fmt" | 5 "fmt" |
6 "html/template" | 6 "html/template" |
7 "net/http" | 7 "net/http" |
8 "net/url" | 8 "net/url" |
9 "path/filepath" | 9 "path/filepath" |
10 "regexp" | 10 "regexp" |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 unavailable := storages.DiffStore.UnavailableDigests() | 1403 unavailable := storages.DiffStore.UnavailableDigests() |
1404 ret := FailureList{ | 1404 ret := FailureList{ |
1405 DigestFailures: make([]*diff.DigestFailure, 0, len(unavailable))
, | 1405 DigestFailures: make([]*diff.DigestFailure, 0, len(unavailable))
, |
1406 Count: len(unavailable), | 1406 Count: len(unavailable), |
1407 } | 1407 } |
1408 | 1408 |
1409 for _, failure := range unavailable { | 1409 for _, failure := range unavailable { |
1410 ret.DigestFailures = append(ret.DigestFailures, failure) | 1410 ret.DigestFailures = append(ret.DigestFailures, failure) |
1411 } | 1411 } |
1412 | 1412 |
| 1413 sort.Sort(sort.Reverse(diff.DigestFailureSlice(ret.DigestFailures))) |
1413 sendJsonResponse(w, &ret) | 1414 sendJsonResponse(w, &ret) |
1414 } | 1415 } |
1415 | 1416 |
| 1417 // failureClearJSONHandler removes digests from the local cache. |
| 1418 func failureClearJSONHandler(w http.ResponseWriter, r *http.Request) { |
| 1419 user := login.LoggedInAs(r) |
| 1420 if user == "" { |
| 1421 util.ReportError(w, r, fmt.Errorf("Not logged in."), "You must b
e logged in to clear digests.") |
| 1422 return |
| 1423 } |
| 1424 |
| 1425 digests := []string{} |
| 1426 dec := json.NewDecoder(r.Body) |
| 1427 if err := dec.Decode(&digests); err != nil { |
| 1428 util.ReportError(w, r, err, "Unable to decode digest list.") |
| 1429 return |
| 1430 } |
| 1431 purgeGS := r.URL.Query().Get("purge") == "true" |
| 1432 |
| 1433 if err := storages.DiffStore.PurgeDigests(digests, purgeGS); err != nil
{ |
| 1434 util.ReportError(w, r, err, "Unable to clear digests.") |
| 1435 } |
| 1436 failureListJSONHandler(w, r) |
| 1437 } |
| 1438 |
1416 // listTrybotsJSONHandler returns a list of issues (Rietveld) that have | 1439 // listTrybotsJSONHandler returns a list of issues (Rietveld) that have |
1417 // trybot results associated with them. | 1440 // trybot results associated with them. |
1418 func listTrybotsJSONHandler(w http.ResponseWriter, r *http.Request) { | 1441 func listTrybotsJSONHandler(w http.ResponseWriter, r *http.Request) { |
1419 var trybotRuns []*search.TrybotIssue | 1442 var trybotRuns []*search.TrybotIssue |
1420 var total int | 1443 var total int |
1421 | 1444 |
1422 offset, size, err := util.PaginationParams(r.URL.Query(), 0, DEFAULT_PAG
E_SIZE, MAX_PAGE_SIZE) | 1445 offset, size, err := util.PaginationParams(r.URL.Query(), 0, DEFAULT_PAG
E_SIZE, MAX_PAGE_SIZE) |
1423 if err == nil { | 1446 if err == nil { |
1424 trybotRuns, total, err = search.ListTrybotIssues(storages, offse
t, size) | 1447 trybotRuns, total, err = search.ListTrybotIssues(storages, offse
t, size) |
1425 } | 1448 } |
(...skipping 30 matching lines...) Expand all Loading... |
1456 } | 1479 } |
1457 | 1480 |
1458 // Init figures out where the resources are and then loads the templates. | 1481 // Init figures out where the resources are and then loads the templates. |
1459 func Init() { | 1482 func Init() { |
1460 if *resourcesDir == "" { | 1483 if *resourcesDir == "" { |
1461 _, filename, _, _ := runtime.Caller(0) | 1484 _, filename, _, _ := runtime.Caller(0) |
1462 *resourcesDir = filepath.Join(filepath.Dir(filename), "../..") | 1485 *resourcesDir = filepath.Join(filepath.Dir(filename), "../..") |
1463 } | 1486 } |
1464 loadTemplates() | 1487 loadTemplates() |
1465 } | 1488 } |
OLD | NEW |