<commit_before>﻿//*********************************************************//
//    Copyright (c) Microsoft. All rights reserved.
//    
//    Apache 2.0 License
//    
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    
//    Unless required by applicable law or agreed to in writing, software 
//    distributed under the License is distributed on an "AS IS" BASIS, 
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
//    implied. See the License for the specific language governing 
//    permissions and limitations under the License.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;
using Orleans.Concurrency;
using Orleans.Samples.Chirper.GrainInterfaces;
using Orleans.Providers;

namespace Orleans.Samples.Chirper.Grains
{
    public interface IChirperAccountState : IGrainState
    {
        /// <summary>The list of publishers who this user is following</summary>
        Dictionary<ChirperUserInfo, IChirperPublisher> Subscriptions { get; set; }

        /// <summary>The list of subscribers who are following this user</summary>
        Dictionary<ChirperUserInfo, IChirperSubscriber> Followers { get; set; }

        /// <summary>Size for the recently received message cache</summary>
        int ReceivedMessagesCacheSize { get; set; }

        /// <summary>Size for the published message cache</summary>
        int PublishedMessagesCacheSize { get; set; }

        /// <summary>Chirp messages recently received by this user</summary>
        Queue<ChirperMessage> RecentReceivedMessages { get; set; }

        /// <summary>Chirp messages recently received by this user</summary>
        Queue<ChirperMessage> MyPublishedMessages { get; set; }

        long UserId { get; set; }

        /// <summary>Alias / username for this actor / user</summary>
        string UserAlias { get; set;  }
    }

    [Reentrant]
    [StorageProvider(ProviderName = "MemoryStore")]
    public class ChirperAccount : Grain<IChirperAccountState>, IChirperAccount
    {
        [NonSerialized]
        private ObserverSubscriptionManager<IChirperViewer> viewers;

        [NonSerialized]
        private Logger logger;

        private const int MAX_MESSAGE_LENGTH = 280;

        private string Me
        {
            get
            {
                return String.Format("I am: [{0}.{1}]", State.UserAlias, State.UserId);
            }
        }

        #region Grain overrides

        public override Task OnActivateAsync()<commit_msg>Fix documentation summary for Chirper sample<commit_after>﻿//*********************************************************//
//    Copyright (c) Microsoft. All rights reserved.
//    
//    Apache 2.0 License
//    
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    
//    Unless required by applicable law or agreed to in writing, software 
//    distributed under the License is distributed on an "AS IS" BASIS, 
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
//    implied. See the License for the specific language governing 
//    permissions and limitations under the License.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;
using Orleans.Concurrency;
using Orleans.Samples.Chirper.GrainInterfaces;
using Orleans.Providers;

namespace Orleans.Samples.Chirper.Grains
{
    public interface IChirperAccountState : IGrainState
    {
        /// <summary>The list of publishers who this user is following</summary>
        Dictionary<ChirperUserInfo, IChirperPublisher> Subscriptions { get; set; }

        /// <summary>The list of subscribers who are following this user</summary>
        Dictionary<ChirperUserInfo, IChirperSubscriber> Followers { get; set; }

        /// <summary>Size for the recently received message cache</summary>
        int ReceivedMessagesCacheSize { get; set; }

        /// <summary>Size for the published message cache</summary>
        int PublishedMessagesCacheSize { get; set; }

        /// <summary>Chirp messages recently received by this user</summary>
        Queue<ChirperMessage> RecentReceivedMessages { get; set; }

        /// <summary>Chirp messages recently published by this user</summary>
        Queue<ChirperMessage> MyPublishedMessages { get; set; }

        long UserId { get; set; }

        /// <summary>Alias / username for this actor / user</summary>
        string UserAlias { get; set;  }
    }

    [Reentrant]
    [StorageProvider(ProviderName = "MemoryStore")]
    public class ChirperAccount : Grain<IChirperAccountState>, IChirperAccount
    {
        [NonSerialized]
        private ObserverSubscriptionManager<IChirperViewer> viewers;

        [NonSerialized]
        private Logger logger;

        private const int MAX_MESSAGE_LENGTH = 280;

        private string Me
        {
            get
            {
                return String.Format("I am: [{0}.{1}]", State.UserAlias, State.UserId);
            }
        }

        #region Grain overrides

        public override Task OnActivateAsync()
{'fraction_non_alphanumeric': 0.12916358253145818, 'fraction_numerical': 0.0033308660251665434, 'mean_word_length': 2.8497150997150995, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3851', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1377, 'n_words': 436}