<commit_before>package main

import (
	"database/sql"
	"strconv"
	"time"
)

type VoteChoice string
type VoteID uint64

const (
	Hot     = VoteChoice("hot")
	Comfort = VoteChoice("comfort")
	Cold    = VoteChoice("cold")
)

type Vote struct {
	VoteID    VoteID
	RoomID    RoomID
	S         *Session
	Choice    VoteChoice
	Timestamp time.Time
}

// 投票内容を変更する。VoteID, RoomID, Sが指定されていなければならない。
// 初投票の場合は、VoteIDはデフォルト値(VoteID(0))に設定すること。
func (v *Vote) UpdateChoice(tx *sql.Tx, choice VoteChoice) error {
	now := time.Now()
	if v.VoteID == VoteID(0) {
		// 初投票の場合
		if _, err := tx.Exec(`
			INSERT INTO vote(
				session_id, room_id, choice, timestamp
			) VALUES (?, ?, ?, ?)`,
			v.S.SessionID, v.RoomID, string(v.Choice), now,
		); err != nil {
			return err
		}
	} else {
		// 投票内容を変更する場合
		if _, err := tx.Exec(`
			UPDATE vote SET choice=?, timestamp=? WHERE vote_id=?`,
			string(choice), now, v.VoteID,
		); err != nil {
			return err
		}
	}
	v.Choice = choice
	v.Timestamp = now
	return nil
}

type RoomID uint64
type BuildingName string
type FloorID int64

type Room struct {
	RoomID       RoomID
	Name         string
	BuildingName BuildingName
	FloorID      FloorID
}
<commit_msg>fix bug<commit_after>package main

import (
	"database/sql"
	"strconv"
	"time"
)

type VoteChoice string
type VoteID uint64

const (
	Hot     = VoteChoice("hot")
	Comfort = VoteChoice("comfort")
	Cold    = VoteChoice("cold")
)

type Vote struct {
	VoteID    VoteID
	RoomID    RoomID
	S         *Session
	Choice    VoteChoice
	Timestamp time.Time
}

// 投票内容を変更する。VoteID, RoomID, Sが指定されていなければならない。
// 初投票の場合は、VoteIDはデフォルト値(VoteID(0))に設定すること。
func (v *Vote) UpdateChoice(tx *sql.Tx, choice VoteChoice) error {
	now := time.Now()
	if v.VoteID == VoteID(0) {
		// 初投票の場合
		if _, err := tx.Exec(`
			INSERT INTO vote(
				session_id, room_id, choice, timestamp
			) VALUES (?, ?, ?, ?)`,
			v.S.SessionID, v.RoomID, string(choice), now,
		); err != nil {
			return err
		}
	} else {
		// 投票内容を変更する場合
		if _, err := tx.Exec(`
			UPDATE vote SET choice=?, timestamp=? WHERE vote_id=?`,
			string(choice), now, v.VoteID,
		); err != nil {
			return err
		}
	}
	v.Choice = choice
	v.Timestamp = now
	return nil
}

type RoomID uint64
type BuildingName string
type FloorID int64

type Room struct {
	RoomID       RoomID
	Name         string
	BuildingName BuildingName
	FloorID      FloorID
}

{'fraction_non_alphanumeric': 0.12288851351351351, 'fraction_numerical': 0.006756756756756757, 'mean_word_length': 3.0634648370497426, 'pattern_counts': {'":': 0, '<': 3, '<?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': '383482', 'n_tokens_mistral': 1052, 'n_tokens_neox': 977, 'n_words': 229}