<commit_before>package services

import (
	// "fmt"
	// "log"
	// "time"
	// "database/sql"
	// "strconv"

	"backend/dao"
	"backend/errors"
	"backend/models"
	// "backend/models/sobjects"
	"backend/utils"

	// "code.google.com/p/go.crypto/bcrypt"
	// "github.com/hishboy/gocommons/lang"
)

var matchQueue *utils.MatchQueue

func init() {
	matchQueue = utils.NewQueue()
}

func GetMatches(playerId string, completed bool) ([]*models.Match, *errors.ServerError) {
	var matches []*models.Match
	var err error
	if completed {
		matches, err = dao.GetMatches(playerId, true)
	} else {
		matches, err = dao.GetMatches(playerId, false)
	}
	if err != nil {
		return nil, errors.New(err, "Unable to retrieve matches", 500)
	}

	return matches, nil
}

func GetMatch(matchId string) (*models.Match, *errors.ServerError) {
	match, err := dao.GetMatchById(matchId)
	if err != nil {
		return nil, errors.New(err, "Unable to retrieve match", 500)
	}

	return match, nil
}

func FindMatch(playerId string) (*models.Match, *errors.ServerError) {
	//Look for an available Player
	player, err := GetPlayer(playerId)
	if err != nil {
		return nil, err
	}

	matchPlayer := matchQueue.PollInsert(player)

	if matchPlayer != nil {
		//set up match
		match, matchErr := dao.InsertMatch(*matchPlayer.Id, *player.Id)
		if matchErr != nil {
			return nil, errors.New(err, "Could not create match", 500)<commit_msg>Cleaned up a goofy bit of lines<commit_after>package services

import (
	// "fmt"
	// "log"
	// "time"
	// "database/sql"
	// "strconv"

	"backend/dao"
	"backend/errors"
	"backend/models"
	// "backend/models/sobjects"
	"backend/utils"

	// "code.google.com/p/go.crypto/bcrypt"
	// "github.com/hishboy/gocommons/lang"
)

var matchQueue *utils.MatchQueue

func init() {
	matchQueue = utils.NewQueue()
}

func GetMatches(playerId string, completed bool) ([]*models.Match, *errors.ServerError) {
	matches, err := dao.GetMatches(playerId, completed)
	if err != nil {
		return nil, errors.New(err, "Unable to retrieve matches", 500)
	}

	return matches, nil
}

func GetMatch(matchId string) (*models.Match, *errors.ServerError) {
	match, err := dao.GetMatchById(matchId)
	if err != nil {
		return nil, errors.New(err, "Unable to retrieve match", 500)
	}

	return match, nil
}

func FindMatch(playerId string) (*models.Match, *errors.ServerError) {
	//Look for an available Player
	player, err := GetPlayer(playerId)
	if err != nil {
		return nil, err
	}

	matchPlayer := matchQueue.PollInsert(player)

	if matchPlayer != nil {
		//set up match
		match, matchErr := dao.InsertMatch(*matchPlayer.Id, *player.Id)
		if matchErr != nil {
			return nil, errors.New(err, "Could not create match", 500)
{'fraction_non_alphanumeric': 0.1469158878504673, 'fraction_numerical': 0.0067289719626168224, 'mean_word_length': 3.9281767955801103, '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': '3259300', 'n_tokens_mistral': 997, 'n_tokens_neox': 951, 'n_words': 240}