<commit_before>package nl.tuvok.elobeggers.services;

import java.util.List;

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;

import com.google.gson.Gson;
import com.mongodb.MongoClient;

import nl.tuvok.elobeggers.models.User;

public class UserService {
	User nullUser;
	final Datastore datastore;
	
	public UserService(Datastore ds) {
		datastore = ds;
		
		nullUser = new User();
		nullUser.name = "Null";
		nullUser.email = "<EMAIL>";
	}

	// returns a list of all users
	public List<User> getAllUsers() {	
		return datastore.find(User.class).asList();
	}

	// returns a single user by id
	public User getUser(String id) {
		return datastore.get(User.class, id);
	}

	// creates a new user
	public User createUser(String name, String email) {
		// make a document and insert it
		final User user = new User();
		user.name = name;
		user.email = email;
		datastore.save(user);
		return user;
	}

	// updates an existing user
	public User updateUser(String id, String name, String email) {
		// ..<commit_msg>Reference users by objectid, eg. http://localhost:4567/user/deadcafebabe12345676<commit_after>package nl.tuvok.elobeggers.services;

import java.util.List;

import org.bson.types.ObjectId;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;

import com.google.gson.Gson;
import com.mongodb.MongoClient;

import nl.tuvok.elobeggers.models.User;

public class UserService {
	User nullUser;
	final Datastore datastore;
	
	public UserService(Datastore ds) {
		datastore = ds;
		
		nullUser = new User();
		nullUser.name = "Null";
		nullUser.email = "<EMAIL>";
	}

	// returns a list of all users
	public List<User> getAllUsers() {	
		return datastore.find(User.class).asList();
	}

	// returns a single user by id
	public User getUser(String id) {
		return datastore.get(User.class, new ObjectId(id));
	}

	// creates a new user
	public User createUser(String name, String email) {
		// make a document and insert it
		final User user = new User();
		user.name = name;
		user.email = email;
		datastore.save(user);
		return user;
	}

	// updates an existing user
	public User updateUser(String id, String name, String email) {
		// ..
{'fraction_non_alphanumeric': 0.11410314924691921, 'fraction_numerical': 0.005476951163852123, 'mean_word_length': 3.775599128540305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '935060', 'n_tokens_mistral': 816, 'n_tokens_neox': 760, 'n_words': 204}