<commit_before>package modelhelper

import (
	"koding/db/models"

	mgo "gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

const (
	CombinedAppStorageColl = "jCombinedAppStorages"
)

// RemoveCombinedAppStorage removes given cas
func RemoveCombinedAppStorage(id bson.ObjectId) error {
	return RemoveDocument(CombinedAppStorageColl, id)
}

func GetCombinedAppStorageByAccountId(accountId bson.ObjectId) (*models.CombinedAppStorage, error) {
	appStorage := &models.CombinedAppStorage{}

	query := func(c *mgo.Collection) error {
		return c.Find(bson.M{"accountId": accountId}).One(appStorage)
	}

	return appStorage, Mongo.Run(CombinedAppStorageColl, query)
}

func CreateCombinedAppStorage(a *models.CombinedAppStorage) error {
	query := insertQuery(a)
	return Mongo.Run(CombinedAppStorageColl, query)
}

func UpdateCombinedAppStorage(a *models.CombinedAppStorage) error {
	query := func(c *mgo.Collection) error {
		return c.UpdateId(a.Id, a)
	}

	return Mongo.Run(CombinedAppStorageColl, query)
}<commit_msg>go/mongomodels: fetchAllCombinedAppStorages with acc ID<commit_after>package modelhelper

import (
	"koding/db/models"

	mgo "gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

const (
	CombinedAppStorageColl = "jCombinedAppStorages"
)

// RemoveCombinedAppStorage removes given cas
func RemoveCombinedAppStorage(id bson.ObjectId) error {
	return RemoveDocument(CombinedAppStorageColl, id)
}

func GetCombinedAppStorageByAccountId(accountId bson.ObjectId) (*models.CombinedAppStorage, error) {
	appStorage := &models.CombinedAppStorage{}

	query := func(c *mgo.Collection) error {
		return c.Find(bson.M{"accountId": accountId}).One(appStorage)
	}

	return appStorage, Mongo.Run(CombinedAppStorageColl, query)
}
func GetAllCombinedAppStorageByAccountId(accountId bson.ObjectId) ([]models.CombinedAppStorage, error) {
	appStorages := make([]models.CombinedAppStorage, 0)

	query := func(c *mgo.Collection) error {
		return c.Find(bson.M{"accountId": accountId}).All(&appStorages)
	}

	return appStorages, Mongo.Run(CombinedAppStorageColl, query)
}

func CreateCombinedAppStorage(a *models.CombinedAppStorage) error {
	query := insertQuery(a)
	return Mongo.Run(CombinedAppStorageColl, query)
}

func UpdateCombinedAppStorage(a *models.CombinedAppStorage) error {
	query := func(c *mgo.Collection) error {
		return c.UpdateId(a.Id, a)
	}

	return Mongo.Run(CombinedAppStorageColl, query)
}
{'fraction_non_alphanumeric': 0.11465770684586309, 'fraction_numerical': 0.0020999580008399833, 'mean_word_length': 6.374613003095975, 'pattern_counts': {'":': 3, '<': 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': '4663523', 'n_tokens_mistral': 856, 'n_tokens_neox': 828, 'n_words': 147}