<commit_before>﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;

namespace DroidRepository
{
    public class DroidRepository : IDroidRepository
    {
        private static ConcurrentDictionary<string, Droid> repo { get; set; }
        private static int id;
        public DroidRepository()
        {
            repo = new ConcurrentDictionary<string, Droid>();
            Seed();
        }


        public IEnumerable<Droid> GetAll()
        {
            var droids = new List<Droid>();
            foreach (var droid in repo.Values)
            {
                var newDroid = Droid.DeepClone(droid);
                droids.Add(newDroid);
            }
            return droids.OrderBy(d => d.Id);
        }

        public Droid Delete(string name)
        {
            Droid droid;
            repo.TryRemove(name, out droid);
            return droid;
        }

        public Droid Get(string name)
        {
            Droid droid = null;
            if (repo.ContainsKey(name))
            {
                repo.TryGetValue(name, out droid);
            }
            return droid;
        }

        public Droid Get(int id)
        {
            return repo.Values.FirstOrDefault(d => d.Id == id);
        }


        public bool Put(Droid newDroid)
        {
            Droid droid = null;
            repo.TryGetValue(newDroid.Name, out droid);
            if (droid != null)
            {
                return false;
            }

            newDroid.Id = id++;
            repo.TryAdd(newDroid.Name, newDroid);

            return true;
        }

        public Droid Update(Droid droid)
        {
            if (repo.ContainsKey(droid.Name))
            {
                repo[droid.Name] = droid;
                return droid;
            }
            return null;
        }

        public IEnumerable<Droid> GetAllFromEntryDate(DateTime entryDate)
        {
            return repo.Values.Where(d => d.EntryDate.CompareTo(entryDate) > 0);
        }

        public IEnumerable<Droid> GetAllTallerThan(decimal height)
        {
            return repo.Values.Where(d => d.Height > height);
        }

        public Droid GetByImperialId(Guid imperialId)
        {
            return repo.Values.FirstOrDefault(d => d.ImperialContractId.Equals(imperialId));
        }

        public IEnumerable<Droid> GetByCreditBalance(long creditBalance)
        {
            return repo.Values.Where(d => d.CreditBalance > creditBalance);
        }
<commit_msg>Update - fixed id on update<commit_after>﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;

namespace DroidRepository
{
    public class DroidRepository : IDroidRepository
    {
        private static ConcurrentDictionary<string, Droid> repo { get; set; }
        private static int id;
        public DroidRepository()
        {
            repo = new ConcurrentDictionary<string, Droid>();
            Seed();
        }


        public IEnumerable<Droid> GetAll()
        {
            var droids = new List<Droid>();
            foreach (var droid in repo.Values)
            {
                var newDroid = Droid.DeepClone(droid);
                droids.Add(newDroid);
            }
            return droids.OrderBy(d => d.Id);
        }

        public Droid Delete(string name)
        {
            Droid droid;
            repo.TryRemove(name, out droid);
            return droid;
        }

        public Droid Get(string name)
        {
            Droid droid = null;
            if (repo.ContainsKey(name))
            {
                repo.TryGetValue(name, out droid);
            }
            return droid;
        }

        public Droid Get(int id)
        {
            return repo.Values.FirstOrDefault(d => d.Id == id);
        }


        public bool Put(Droid newDroid)
        {
            Droid droid = null;
            repo.TryGetValue(newDroid.Name, out droid);
            if (droid != null)
            {
                return false;
            }

            newDroid.Id = id++;
            repo.TryAdd(newDroid.Name, newDroid);

            return true;
        }

        public Droid Update(Droid droid)
        {
            if (repo.ContainsKey(droid.Name))
            {
                droid.Id = repo[droid.Name].Id;
                repo[droid.Name] = droid;
                return droid;
            }
            return null;
        }

        public IEnumerable<Droid> GetAllFromEntryDate(DateTime entryDate)
        {
            return repo.Values.Where(d => d.EntryDate.CompareTo(entryDate) > 0);
        }

        public IEnumerable<Droid> GetAllTallerThan(decimal height)
        {
            return repo.Values.Where(d => d.Height > height);
        }

        public Droid GetByImperialId(Guid imperialId)
        {
            return repo.Values.FirstOrDefault(d => d.ImperialContractId.Equals(imperialId));
        }

        public IEnumerable<Droid> GetByCreditBalance(long creditBalance)
        {
            return repo.Values.Where(d => d.CreditBalance > creditBalance);
        }

{'fraction_non_alphanumeric': 0.09013209013209013, 'fraction_numerical': 0.0003885003885003885, 'mean_word_length': 1.4838398456343465, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, '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': '6812631', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1409, 'n_words': 302}