<commit_before>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Serialization;
using System.Linq;
using StorageLibrary;
using Tigwi_API.Models;

namespace Tigwi_API.Controllers
{
    public class InfoListController : ApiController
    {
        //
        // GET : /infolist/subscriptions/{idOfList}/{number}

        public ActionResult Subscriptions(Guid idOfList, int number)
        {
            //TODO: Implement this
            throw new NotImplementedException();
        }

        //
        // GET : /infolist/subscribers/{idOfList}/{number}

        public ActionResult Subscribers(Guid idOfList, int number)
        {
            //TODO: Implement this
            throw new NotImplementedException();
        }

        //
        // GET : /infolist/owner/{idOfList}

        public ActionResult Owner(Guid idOfList)
        {
            //TODO: implement this
            throw new NotImplementedException();
        }

        //
        // GET : /infolist/messages/{idOfList}/{number}

        public ActionResult Messages(Guid idOfList, int number)
        {
            //TODO: implement this
            throw new NotImplementedException();
        }

    }
}<commit_msg>infoListController<commit_after>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Serialization;
using System.Linq;
using StorageLibrary;
using Tigwi_API.Models;

namespace Tigwi_API.Controllers
{
    public class InfoListController : ApiController
    {
        //
        // GET : /infolist/subscriptions/{idOfList}/{number}

        public ActionResult Subscriptions(Guid idOfList, int number)
        {
            Answer output;

            try
            {
                // get accounts following a given list 
                list listFollowedAccounts = storage.List.GetAccounts(idOfList);
                var numberToReturn = Math.Min(number, listFollowedAccounts.count);
                List<user> listFollowedAccountsOutput = listFollowedAccounts.GetRange(numberToReturn, 1);

                output = new Answer(listFollowedAccountsOutput);
            }

            catch (StorageLibException exception)
            {
                output = new Answer(new Error(exception.Code.ToString()));
            }

            var stream = new MemoryStream();
            (new XmlSerializer(typeof(Answer))).Serialize(stream, output);

            return Content(stream.ToString());
        }

        //
        // GET : /infolist/subscribers/{idOfList}/{number}

        public ActionResult Subscribers(Guid idOfList, int number)
        {
            Answer output;

            try
            {
                // get accounts following a given list 
                list listSuscribersAccount = storage.List.GetFollowingAccounts(idOfList);
                var numberToReturn = Math.Min(number, listSuscribersAccount.count);
                List<user> listSuscribersOutput = listSuscribersAccount.GetRange(numberToReturn, 1);

                output = new Answer(listSuscribersOutput);
            }
            catch (StorageLibException exception)
            {
                output = new Answer(new Error(exception.Code.ToString()));
            }

            var stream = new MemoryStream();
            (new XmlSerializer(typeof(Answer))).Serialize(stream, output);

            return Content(stream.ToString());
        }


        //
        // GET : /infolist/owner/{idOfList}

        public ActionResult Owner(Guid idOfList)
        {
            Answer output;

            try
            {
                // get accounts following a given list 
                var owner = storage.List.GetOwner(idOfList);

                output = new Answer(owner);
            }

            catch (StorageLibException exception)
            {
                output = new Answer(new Error(exception.Code.ToString()));
            }

            var stream = new MemoryStream();
            (new XmlSerializer(typeof(Answer))).Serialize(stream, output);

            return Content(stream.ToString());
        }

        //
        // GET : /infolist/messages/{idOfList}/{number}

        public ActionResult Messages(Guid idOfList, int number)
        {
            Answer output;

            try
            {
                // get lasts messages from list defined by idOfList
                list listMsgs = storage.Msg.GetListsMsgTo(new HashSet<Guid> { idOfList }, DateTime.Now, number);

                // convert, looking forward XML serialization
                var listMsgsOutput = new Messages(listMsgs, storage);

                output = new Answer(listMsgsOutput);
            }
            catch (StorageLibException exception)
            {
                output = new Answer(new Error(exception.Code.ToString()));
            }

            var stream = new MemoryStream();
            (new XmlSerializer(typeof(Answer))).Serialize(stream, output);

            return Content(stream.ToString());
        }

    }
}
{'fraction_non_alphanumeric': 0.09074733096085409, 'fraction_numerical': 0.00039541320680110717, 'mean_word_length': 1.7781438769906646, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '6431368', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1240, 'n_words': 284}