<commit_before>package main

import (
	"appengine"
	"appengine/datastore"
	"appengine/search"
	"appengine/taskqueue"
	"archive/zip"
	"encoding/json"
	"net/http"
	"strconv"
	"strings"
	"time"
)

type Export struct {
	Context appengine.Context
}

func (x *Export) User(userIdStr string, w http.ResponseWriter) {
	db := DB{x.Context}
	userId, _ := strconv.ParseInt(userIdStr, 10, 64)

	user, err := db.GetUser(userId)
	if err != nil {
		x.Context.Errorf("got err on export: %v", err)
		return
	}

	userMeta, _ := json.MarshalIndent(user.UserMeta, "", "  ")
	userData, _ := json.MarshalIndent(user.UserData, "", "  ")

	w.Header().Add("Content-Type", "application/zip")
	zipWriter := zip.NewWriter(w)

	var files = []struct {
		Name, Data string
	}{
		{"UserMeta.json", string(userMeta)},
		{"UserData.json", string(userData)},
	}
	for _, file := range files {
		f, err := zipWriter.Create(file.Name)
		if err != nil {
			x.Context.Errorf(err.Error())
		}
		_, err = f.Write([]byte(file.Data))
		if err != nil {
			x.Context.Errorf(err.Error())
		}
	}

	err = zipWriter.Close()
	if err != nil {
		x.Context.Errorf(err.Error())
	}
}

func QueueUser(userId string, c appengine.Context) {
	vineApi := VineRequest{c}
	user, err := vineApi.GetUser(userId)
	if err == nil {

		key := datastore.NewKey(c, "Queue", "", user.UserId, nil)

		var data QueuedUser
		if len(user.VanityUrls) > 0 {
			data = QueuedUser{strings.ToLower(user.VanityUrls[0]), time.Now()}
		} else {<commit_msg>Added UserRecord to user export.<commit_after>package main

import (
	"appengine"
	"appengine/datastore"
	"appengine/search"
	"appengine/taskqueue"
	"archive/zip"
	"encoding/json"
	"net/http"
	"strconv"
	"strings"
	"time"
)

type Export struct {
	Context appengine.Context
}

func (x *Export) User(userIdStr string, w http.ResponseWriter) {
	db := DB{x.Context}
	userId, _ := strconv.ParseInt(userIdStr, 10, 64)

	user, err := db.GetUser(userId)
	if err != nil {
		x.Context.Errorf("got err on export: %v", err)
		return
	}

	userMeta, _ := json.MarshalIndent(user.UserMeta, "", "  ")
	userData, _ := json.MarshalIndent(user.UserData, "", "  ")
	user.UserMeta, user.UserData = nil, nil
	userJson, _ := json.MarshalIndent(user, "", "  ")

	w.Header().Add("Content-Type", "application/zip")
	zipWriter := zip.NewWriter(w)

	var files = []struct {
		Name, Data string
	}{
		{"UserRecord.json", string(userJson)},
		{"UserData.json", string(userData)},
		{"UserMeta.json", string(userMeta)},
	}
	for _, file := range files {
		f, err := zipWriter.Create(file.Name)
		if err != nil {
			x.Context.Errorf(err.Error())
		}
		_, err = f.Write([]byte(file.Data))
		if err != nil {
			x.Context.Errorf(err.Error())
		}
	}

	err = zipWriter.Close()
	if err != nil {
		x.Context.Errorf(err.Error())
	}
}

func QueueUser(userId string, c appengine.Context) {
	vineApi := VineRequest{c}
	user, err := vineApi.GetUser(userId)
	if err == nil {

		key := datastore.NewKey(c, "Queue", "", user.UserId, nil)

		var data QueuedUser
		if len(user.VanityUrls) > 0 {
			data = QueuedUser{strings.ToLower(user.VanityUrls[0]), time.Now()}
		} else {
{'fraction_non_alphanumeric': 0.1740956072351421, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 3.9236883942766294, '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': '6217857', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1182, 'n_words': 238}