<commit_before>package models

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"time"
)

type Collection struct {
	Id       string `json:"id"`
	Title    string `json:"title" form:"title"`
	Subtitle string `json:"subtitle" form:"subtitle"`
	Author   string `json:"author"`
	Date     string `json:"date"`
}

func AllCollections() ([]Collection, error) {
	result, err := db.Do("hsize", h_collection)
	if err != nil {
		return []Collection{}, err
	}
	size, _ := strconv.Atoi(result[1])
	if size == 0 {
		return []Collection{}, nil
	}

	result, err = db.Do("hscan", h_collection, "", "", size)
	if err != nil {
		return []Collection{}, err
	}
	status := result[0]
	if status != "ok" {
		return []Collection{}, errors.New(status)
	}

	collections := []Collection{}
	for i := 2; i < len(result); i += 2 {
		c := Collection{}
		_ = json.Unmarshal([]byte(result[i]), &c)
		collections = append(collections, c)
	}

	return collections, nil
}

func CollectionsByUser(name string) ([]Collection, error) {
	result, err := db.Do("zsize", "blog_"+name+"_collection")
	if err != nil {
		return []Collection{}, err
	}
	size, _ := strconv.Atoi(result[1])
	if size == 0 {
		return []Collection{}, nil<commit_msg>Fix date display bug.<commit_after>package models

import (
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"time"
)

type Collection struct {
	Id       string `json:"id"`
	Title    string `json:"title" form:"title"`
	Subtitle string `json:"subtitle" form:"subtitle"`
	Author   string `json:"author"`
	Date     string `json:"date"`
}

func AllCollections() ([]Collection, error) {
	result, err := db.Do("hsize", h_collection)
	if err != nil {
		return []Collection{}, err
	}
	size, _ := strconv.Atoi(result[1])
	if size == 0 {
		return []Collection{}, nil
	}

	result, err = db.Do("hscan", h_collection, "", "", size)
	if err != nil {
		return []Collection{}, err
	}
	status := result[0]
	if status != "ok" {
		return []Collection{}, errors.New(status)
	}

	collections := []Collection{}
	for i := 2; i < len(result); i += 2 {
		c := Collection{}
		_ = json.Unmarshal([]byte(result[i]), &c)
		t, _ := time.Parse(time.RFC3339, c.Date)
		c.Date = t.Format(time.ANSIC)
		collections = append(collections, c)
	}

	return collections, nil
}

func CollectionsByUser(name string) ([]Collection, error) {
	result, err := db.Do("zsize", "blog_"+name+"_collection")
	if err != nil {
		return []Collection{}, err
	}
	size, _ := strconv.Atoi(result[1])
	if size == 0 {
		return []Collection{}, nil
{'fraction_non_alphanumeric': 0.18445428916633105, 'fraction_numerical': 0.00724929520741039, 'mean_word_length': 4.079754601226994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7618801', 'n_tokens_mistral': 921, 'n_tokens_neox': 881, 'n_words': 229}