<commit_before>package app

import (
	"errors"
	"fmt"
	"net/http"
	"time"

	"appengine"
	"appengine/datastore"
	"appengine/user"
)

type uLogData struct {
	Time time.Time
}

func logUser(c appengine.Context) error {
	u := user.Current(c)
	if u == nil {
		return errors.New("User should be logged in before calling logUser.")
	}
	key := datastore.NewKey(c, "userLog", u.ID, 0, nil)
	now := uLogData{time.Now()}
	_, err := datastore.Put(c, key, &now)
	return err
}

func vanity(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	since := time.Now().Add(-30 * 24 * time.Hour)
	q := datastore.NewQuery("userLog").Filter("Time>", since).Order("-Time")
	count, err := q.Count(c)
	if err != nil {
		handleError(w, err)
		return
	}
	fmt.Fprintf(w, "%d unique visitors in the last 30 days. First 100:\n", count)
	q = q.Limit(100)
	times := make([]uLogData, 0, 100)
	ks, err := q.GetAll(c, &times)
	if err != nil {
		handleError(w, err)
		return
	}
	for i, k := range ks {
		fmt.Fprintf(w, "%v: %s\n", times[i].Time, k.StringID())
	}
	fmt.Fprintf(w, "I am %s\n", user.Current(c).ID)<commit_msg>Content type for vanity page<commit_after>package app

import (
	"errors"
	"fmt"
	"net/http"
	"time"

	"appengine"
	"appengine/datastore"
	"appengine/user"
)

type uLogData struct {
	Time time.Time
}

func logUser(c appengine.Context) error {
	u := user.Current(c)
	if u == nil {
		return errors.New("User should be logged in before calling logUser.")
	}
	key := datastore.NewKey(c, "userLog", u.ID, 0, nil)
	now := uLogData{time.Now()}
	_, err := datastore.Put(c, key, &now)
	return err
}

func vanity(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/plain")
	c := appengine.NewContext(r)
	since := time.Now().Add(-30 * 24 * time.Hour)
	q := datastore.NewQuery("userLog").Filter("Time>", since).Order("-Time")
	count, err := q.Count(c)
	if err != nil {
		handleError(w, err)
		return
	}
	fmt.Fprintf(w, "%d unique visitors in the last 30 days. First 100:\n", count)
	q = q.Limit(100)
	times := make([]uLogData, 0, 100)
	ks, err := q.GetAll(c, &times)
	if err != nil {
		handleError(w, err)
		return
	}
	for i, k := range ks {
		fmt.Fprintf(w, "%v: %s\n", times[i].Time, k.StringID())
	}
	fmt.Fprintf(w, "I am %s\n", user.Current(c).ID)
{'fraction_non_alphanumeric': 0.18521777386713595, 'fraction_numerical': 0.014958205015398152, 'mean_word_length': 3.8382978723404255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6142736', 'n_tokens_mistral': 973, 'n_tokens_neox': 928, 'n_words': 231}