<commit_before>﻿using System.Linq;
using System.Web.Http;
using System.Web.Http.OData;
using NuGet.Lucene.Web.Models;
using NuGet.Lucene.Web.Util;

namespace NuGet.Lucene.Web.Controllers
{
    /// <summary>
    /// OData provider for Lucene based NuGet package repository.
    /// </summary>
    public class PackagesODataController : ODataController
    {
        public ILucenePackageRepository Repository { get; set; }
        public IMirroringPackageRepository MirroringRepository { get; set; }

        [Queryable]
        public IQueryable<ODataPackage> Get()
        {
            return Repository.LucenePackages.Select(p => p.AsDataServicePackage()).AsQueryable();
        }

        public object Get([FromODataUri] string id, [FromODataUri] string version)
        {
            SemanticVersion semanticVersion;
            if (!SemanticVersion.TryParse(version, out semanticVersion))
            {
                return BadRequest("Invalid version");
            }

            if (string.IsNullOrWhiteSpace(id))
            {
                return BadRequest("Invalid package id");
            }

            var package = MirroringRepository.FindPackage(id, semanticVersion);

            return package == null ? (object)NotFound() : package.AsDataServicePackage();
        }
    }
}<commit_msg>Set more specific return type to enable application/atom+xml response formatting.<commit_after>﻿using System.Linq;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.OData;
using NuGet.Lucene.Web.Models;
using NuGet.Lucene.Web.Util;

namespace NuGet.Lucene.Web.Controllers
{
    /// <summary>
    /// OData provider for Lucene based NuGet package repository.
    /// </summary>
    public class PackagesODataController : ODataController
    {
        public ILucenePackageRepository Repository { get; set; }
        public IMirroringPackageRepository MirroringRepository { get; set; }

        [Queryable]
        public IQueryable<ODataPackage> Get()
        {
            return Repository.LucenePackages.Select(p => p.AsDataServicePackage()).AsQueryable();
        }

        public IHttpActionResult Get([FromODataUri] string id, [FromODataUri] string version)
        {
            SemanticVersion semanticVersion;
            if (!SemanticVersion.TryParse(version, out semanticVersion))
            {
                return BadRequest("Invalid version");
            }

            if (string.IsNullOrWhiteSpace(id))
            {
                return BadRequest("Invalid package id");
            }

            var package = MirroringRepository.FindPackage(id, semanticVersion);

            return package == null ? (IHttpActionResult)NotFound() : Ok(package.AsDataServicePackage());
        }
    }
}
{'fraction_non_alphanumeric': 0.09558555271798613, 'fraction_numerical': 0.0, 'mean_word_length': 2.470886075949367, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '7659093', 'n_tokens_mistral': 735, 'n_tokens_neox': 718, 'n_words': 161}