<commit_before>package models

import (
	"encoding/xml"
	"errors"
	"time"

	"github.com/koding/bongo"
)

var ErrNotSet = errors.New("name is not set")

type SitemapFile struct {
	Id int64

	// unique file name
	Name string `sql:"NOT NULL"`

	// file content
	Blob []byte

	// creation date of the file
	CreatedAt time.Time

	// last modification date of the file
	UpdatedAt time.Time
}

func NewSitemapFile() *SitemapFile {
	return &SitemapFile{}
}

func (f SitemapFile) GetId() int64 {
	return f.Id
}

func (f SitemapFile) TableName() string {
	return "sitemap.file"
}

func (f *SitemapFile) BeforeCreate() error {
	if f.Name == "" {
		return ErrNotSet
	}

	return nil
}

func (f *SitemapFile) Create() error {
	return bongo.B.Create(f)
}

func (f *SitemapFile) One(q *bongo.Query) error {
	return bongo.B.One(f, f, q)
}

func (f *SitemapFile) ByName(name string) error {
	if name == "" {
		return ErrNotSet
	}

	selector := map[string]interface{}{
		"name": name,
	}
	q := bongo.NewQS(selector)

	return f.One(q)
}

func (f *SitemapFile) Update() error {
	return bongo.B.Update(f)
}

func (f *SitemapFile) Some(data interface{}, q *bongo.Query) error {
	return bongo.B.Some(f, data, q)
}

func (f *SitemapFile) ById(id int64) error {
	return bongo.B.ById(f, id)
}

func (f *SitemapFile) UnmarshalBlob() (*ItemSet, error) {
	set := NewItemSet()

	return set, xml.Unmarshal(f.Blob, set)
}

func (f *SitemapFile) Delete() error {
	return bongo.B.Delete(f)
}<commit_msg>Sitemap: Add purge method<commit_after>package models

import (
	"encoding/xml"
	"errors"
	"time"

	"github.com/koding/bongo"
)

var ErrNotSet = errors.New("name is not set")

type SitemapFile struct {
	Id int64

	// unique file name
	Name string `sql:"NOT NULL"`

	// file content
	Blob []byte

	// creation date of the file
	CreatedAt time.Time

	// last modification date of the file
	UpdatedAt time.Time
}

func NewSitemapFile() *SitemapFile {
	return &SitemapFile{}
}

func (f SitemapFile) GetId() int64 {
	return f.Id
}

func (f SitemapFile) TableName() string {
	return "sitemap.file"
}

func (f *SitemapFile) BeforeCreate() error {
	if f.Name == "" {
		return ErrNotSet
	}

	return nil
}

func (f *SitemapFile) Create() error {
	return bongo.B.Create(f)
}

func (f *SitemapFile) One(q *bongo.Query) error {
	return bongo.B.One(f, f, q)
}

func (f *SitemapFile) ByName(name string) error {
	if name == "" {
		return ErrNotSet
	}

	selector := map[string]interface{}{
		"name": name,
	}
	q := bongo.NewQS(selector)

	return f.One(q)
}

func (f *SitemapFile) Update() error {
	return bongo.B.Update(f)
}

func (f *SitemapFile) Some(data interface{}, q *bongo.Query) error {
	return bongo.B.Some(f, data, q)
}

func (f *SitemapFile) ById(id int64) error {
	return bongo.B.ById(f, id)
}

func (f *SitemapFile) UnmarshalBlob() (*ItemSet, error) {
	set := NewItemSet()

	return set, xml.Unmarshal(f.Blob, set)
}

func (f *SitemapFile) Delete() error {
	return bongo.B.Delete(f)
}

func (f *SitemapFile) Purge() error {
	return bongo.B.Purge(f)
}
{'fraction_non_alphanumeric': 0.14465826144658261, 'fraction_numerical': 0.003981420039814201, 'mean_word_length': 3.902439024390244, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3951234', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1202, 'n_words': 322}