<commit_before>package history

import (
	"time"

	"errors"
)

const (
	LoginAccess           = 1 << iota
	RegistrationAccess    = 1 << iota
	TokenValidationAccess = 1 << iota
)

var ErrorBadUserID = errors.New("User ID provided was not good")
var ErrorBadAccessMethod = errors.New("Access Method was unknown")

type History struct {
	id           int
	userID       int
	ipAddress    string
	date         time.Time
	accessMethod int
	forService   string
	referral     string
	successful   bool
}

func (ld *History) ID() int            { return ld.id }
func (ld *History) UserID() int        { return ld.userID }
func (ld *History) IPAddress() string  { return ld.ipAddress }
func (ld *History) Date() time.Time    { return ld.date }
func (ld *History) AccessMethod() int  { return ld.accessMethod }
func (ld *History) ForService() string { return ld.forService }
func (ld *History) Referral() string   { return ld.referral }
func (ld *History) Successful() bool   { return ld.successful }

func (h *History) Validate() error {

	if h.userID == 0 {
		return ErrorBadUserID
	}

	if err := validateAcM(h.accessMethod); err != nil {
		return err
	}

	return nil
}

func New(uID, acM int, successful bool, date time.Time, ip, forSrvc, ref string) (*History, error) {
<commit_msg>Decode access method from int to human readable string<commit_after>package history

import (
	"time"

	"errors"
)

const (
	LoginAccess           = 1 << iota
	RegistrationAccess    = 1 << iota
	TokenValidationAccess = 1 << iota
)

var ErrorBadUserID = errors.New("User ID provided was not good")
var ErrorBadAccessMethod = errors.New("Access Method was unknown")

type History struct {
	id           int
	userID       int
	ipAddress    string
	date         time.Time
	accessMethod int
	forService   string
	referral     string
	successful   bool
}

func (ld *History) ID() int            { return ld.id }
func (ld *History) UserID() int        { return ld.userID }
func (ld *History) IPAddress() string  { return ld.ipAddress }
func (ld *History) Date() time.Time    { return ld.date }
func (ld *History) AccessMethod() int  { return ld.accessMethod }
func (ld *History) ForService() string { return ld.forService }
func (ld *History) Referral() string   { return ld.referral }
func (ld *History) Successful() bool   { return ld.successful }

func (h *History) Validate() error {

	if h.userID == 0 {
		return ErrorBadUserID
	}

	if err := validateAcM(h.accessMethod); err != nil {
		return err
	}

	return nil
}

func DecodeAccessMethod(acM int) string {

	if acM == LoginAccess {
		return "login"
	}

	if acM == TokenValidationAccess {
		return "token validation"
	}

	if acM == RegistrationAccess {
		return "registration"
	}

	return "unknown"
}

func New(uID, acM int, successful bool, date time.Time, ip, forSrvc, ref string) (*History, error) {

{'fraction_non_alphanumeric': 0.10466760961810467, 'fraction_numerical': 0.002828854314002829, 'mean_word_length': 3.286363636363636, 'pattern_counts': {'":': 0, '<': 15, '<?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': '2619254', 'n_tokens_mistral': 933, 'n_tokens_neox': 890, 'n_words': 304}