1
// Copyright 2012 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
7
// This file handles garbage collection of old CLs.
18
http.HandleFunc("/gc", handleGC)
21
func handleGC(w http.ResponseWriter, r *http.Request) {
22
c := appengine.NewContext(r)
24
// Delete closed CLs that haven't been modified in 168 hours (7 days).
25
cutoff := time.Now().Add(-168 * time.Hour)
26
q := datastore.NewQuery("CL").
27
Filter("Closed =", true).
28
Filter("Modified <", cutoff).
31
keys, err := q.GetAll(c, nil)
33
c.Errorf("GetAll failed for old CLs: %v", err)
34
http.Error(w, err.Error(), http.StatusInternalServerError)
41
if err := datastore.DeleteMulti(c, keys); err != nil {
42
c.Errorf("DeleteMulti failed for old CLs: %v", err)
43
http.Error(w, err.Error(), http.StatusInternalServerError)
46
c.Infof("Deleted %d old CLs", len(keys))