Esempio n. 1
0
        private IQueryable <Song> CreateQuery(
            SongQueryParams queryParams,
            ParsedSongQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var query = Query <Song>()
                        .Where(s => !s.Deleted)
                        .WhereHasName(parsedQuery.Name, nameMatchMode ?? queryParams.Common.NameMatchMode)
                        .WhereHasArtistParticipationStatus(queryParams.ArtistId, queryParams.ArtistParticipationStatus, queryParams.ChildVoicebanks, id => querySource.Load <Artist>(id))
                        .WhereDraftsOnly(queryParams.Common.DraftOnly)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasType(queryParams.SongTypes)
                        .WhereHasTag(!string.IsNullOrEmpty(queryParams.Tag) ? queryParams.Tag : parsedQuery.TagName)
                        .WhereArtistHasTag(parsedQuery.ArtistTag)
                        .WhereArtistHasType(parsedQuery.ArtistType)
                        .WhereHasNicoId(parsedQuery.NicoId)
                        .WhereIdNotIn(queryParams.IgnoredIds)
                        .WhereInUserCollection(queryParams.UserCollectionId)
                        .WhereHasLyrics(queryParams.LyricsLanguages);

            query = AddScoreFilter(query, queryParams.MinScore);
            query = AddTimeFilter(query, queryParams.TimeFilter);
            query = AddPVFilter(query, queryParams.OnlyWithPVs);

            return(query);
        }
Esempio n. 2
0
        private IQueryable <Album> CreateQuery(
            AlbumQueryParams queryParams,
            ParsedAlbumQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var artistIds = EntryIdsCollection.CreateWithFallback(queryParams.ArtistParticipation.ArtistIds.Ids, parsedQuery.ArtistId);
            var textQuery = SearchTextQuery.Create(parsedQuery.Name, nameMatchMode ?? queryParams.Common.NameMatchMode);

            var query = Query <Album>()
                        .WhereIsDeleted(queryParams.Deleted)
                        .WhereHasName(textQuery, allowCatNum: true)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasArtistParticipationStatus(queryParams.ArtistParticipation, artistIds, querySource.OfType <Artist>())
                        .WhereHasBarcode(queryParams.Barcode)
                        .WhereHasType(queryParams.AlbumType)
                        .WhereHasTags(queryParams.TagIds, queryParams.ChildTags)
                        .WhereHasTags(queryParams.Tags)
                        .WhereHasTag(parsedQuery.TagName)
                        .WhereReleaseDateIsAfter(queryParams.ReleaseDateAfter)
                        .WhereReleaseDateIsBefore(queryParams.ReleaseDateBefore)
                        .WhereSortBy(queryParams.SortRule)
                        .WhereMatchFilters(queryParams.AdvancedFilters);

            return(query);
        }
Esempio n. 3
0
        private IQueryable <Artist> CreateQuery(
            ArtistQueryParams queryParams,
            NameMatchMode?nameMatchMode = null)
        {
            var query = context.Query()
                        .Where(s => !s.Deleted)
                        .WhereHasName_Canonized(queryParams.Common.Query, matchMode: nameMatchMode ?? queryParams.Common.NameMatchMode)
                        .WhereDraftsOnly(queryParams.Common.DraftOnly)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasType(queryParams.ArtistTypes)
                        .WhereHasTag(queryParams.Tag)
                        .WhereIsFollowedByUser(queryParams.UserFollowerId);

            return(query);
        }
Esempio n. 4
0
        private IQueryable <Song> CreateQuery(
            SongQueryParams queryParams,
            ParsedSongQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var textQuery = !SearchTextQuery.IsNullOrEmpty(parsedQuery.Name) ?
                            new SearchTextQuery(parsedQuery.Name.Query, nameMatchMode ?? parsedQuery.Name.MatchMode, parsedQuery.Name.OriginalQuery)
                                : SearchTextQuery.Empty;

            textQuery = ProcessAdvancedSearch(textQuery, queryParams);

            var typesAndTags = ProcessUnifiedTypesAndTags(queryParams);

            var query = Query <Song>()
                        .WhereNotDeleted()
                        .WhereHasName(textQuery)
                        .WhereHasArtistParticipationStatus(queryParams.ArtistParticipation, _querySource.OfType <Artist>())
                        .WhereHasArtists <Song, ArtistForSong>(queryParams.ArtistNames)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasType(queryParams.SongTypes)
                        .WhereHasTags(queryParams.TagIds, queryParams.ChildTags)
                        .WhereHasTags(queryParams.Tags)
                        .WhereHasTag(parsedQuery.TagName)
                        .WhereHasTypeOrTag(typesAndTags)
                        .WhereArtistHasTag(parsedQuery.ArtistTag)
                        .WhereArtistHasType(parsedQuery.ArtistType)
                        .WhereHasNicoId(parsedQuery.NicoId)
                        .WhereHasPV(parsedQuery.PV)
                        .WhereHasPVService(queryParams.PVServices)
                        .WhereIdIs(parsedQuery.Id)
                        .WhereIdNotIn(queryParams.IgnoredIds)
                        .WhereInUserCollection(queryParams.UserCollectionId)
                        .WhereHasParentSong(queryParams.ParentSongId)
                        .WhereArtistIsFollowedByUser(queryParams.FollowedByUserId)
                        .WhereReleaseEventIs(queryParams.ReleaseEventId)
                        .WherePublishDateIsBetween(parsedQuery.PublishedAfter, parsedQuery.PublishedBefore)
                        .WherePublishDateIsBetween(queryParams.AfterDate, queryParams.BeforeDate)
                        .WhereHasScore(queryParams.MinScore)
                        .WhereCreateDateIsWithin(queryParams.TimeFilter)
                        .WhereHasPV(queryParams.OnlyWithPVs)
                        .WhereMatchFilters(queryParams.AdvancedFilters)
                        .WhereMilliBpmIsBetween(queryParams.MinMilliBpm, queryParams.MaxMilliBpm)
                        .WhereLengthIsBetween(queryParams.MinLength, queryParams.MaxLength);

            return(query);
        }
Esempio n. 5
0
        private IQueryable <Album> CreateQuery(
            AlbumQueryParams queryParams,
            ParsedAlbumQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var artistId = queryParams.ArtistId != 0 ? queryParams.ArtistId : parsedQuery.ArtistId;

            var query = Query <Album>()
                        .Where(s => !s.Deleted)
                        .WhereHasName(parsedQuery.Name, nameMatchMode ?? queryParams.Common.NameMatchMode, allowCatNum: true)
                        .WhereDraftsOnly(queryParams.Common.DraftOnly)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasArtistParticipationStatus(artistId, queryParams.ArtistParticipationStatus, queryParams.ChildVoicebanks, id => querySource.Load <Artist>(id))
                        .WhereHasBarcode(queryParams.Barcode)
                        .WhereHasType(queryParams.AlbumType)
                        .WhereHasTag(!string.IsNullOrEmpty(queryParams.Tag) ? queryParams.Tag : parsedQuery.TagName);

            return(query);
        }
Esempio n. 6
0
        private IQueryable <Artist> CreateQuery(
            ArtistQueryParams queryParams,
            ParsedArtistQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var textQuery = (parsedQuery.HasNameQuery ? queryParams.Common.TextQuery.OverrideMatchMode(nameMatchMode) : ArtistSearchTextQuery.Empty);

            var query = context.Query()
                        .Where(s => !s.Deleted)
                        .WhereHasName_Canonized(textQuery)
                        .WhereDraftsOnly(queryParams.Common.DraftOnly)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasExternalLinkUrl(parsedQuery.ExternalLinkUrl)
                        .WhereHasType(queryParams.ArtistTypes)
                        .WhereHasTag(queryParams.Tag)
                        .WhereIdIs(parsedQuery.Id)
                        .WhereIsFollowedByUser(queryParams.UserFollowerId);

            return(query);
        }
Esempio n. 7
0
        private IQueryable <Artist> CreateQuery(
            ArtistQueryParams queryParams,
            ParsedArtistQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var textQuery = (parsedQuery.HasNameQuery ? queryParams.Common.TextQuery.OverrideMatchMode(nameMatchMode) : ArtistSearchTextQuery.Empty);

            var query = _context.Query()
                        .Where(s => !s.Deleted)
                        .WhereHasName_Canonized(textQuery)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasExternalLinkUrl(parsedQuery.ExternalLinkUrl)
                        .WhereHasType(queryParams.ArtistTypes)
                        .WhereHasTags(queryParams.TagIds, queryParams.ChildTags)
                        .WhereHasTags(queryParams.Tags)
                        .WhereIdIs(parsedQuery.Id)
                        .WhereIsFollowedByUser(queryParams.UserFollowerId)
                        .WhereAllowBaseVoicebanks(queryParams.AllowBaseVoicebanks)
                        .WhereMatchFilters(queryParams.AdvancedFilters);

            return(query);
        }
Esempio n. 8
0
        private IQueryable <Song> CreateQuery(
            SongQueryParams queryParams,
            ParsedSongQuery parsedQuery,
            NameMatchMode?nameMatchMode = null)
        {
            var textQuery = !SearchTextQuery.IsNullOrEmpty(parsedQuery.Name) ?
                            new SearchTextQuery(parsedQuery.Name.Query, nameMatchMode ?? parsedQuery.Name.MatchMode, parsedQuery.Name.OriginalQuery)
                                : SearchTextQuery.Empty;

            textQuery = ProcessAdvancedSearch(textQuery, queryParams);

            var query = Query <Song>()
                        .Where(s => !s.Deleted)
                        .WhereHasName(textQuery)
                        .WhereHasArtistParticipationStatus(queryParams.ArtistParticipation, id => querySource.Load <Artist>(id))
                        .WhereHasArtists <Song, ArtistForSong>(queryParams.ArtistNames)
                        .WhereStatusIs(queryParams.Common.EntryStatus)
                        .WhereHasType(queryParams.SongTypes)
                        .WhereHasTags(queryParams.TagIds, queryParams.ChildTags)
                        .WhereHasTags(queryParams.Tags)
                        .WhereHasTag(parsedQuery.TagName)
                        .WhereArtistHasTag(parsedQuery.ArtistTag)
                        .WhereArtistHasType(parsedQuery.ArtistType)
                        .WhereHasNicoId(parsedQuery.NicoId)
                        .WhereHasPV(parsedQuery.PV)
                        .WhereHasPVService(queryParams.PVServices)
                        .WhereIdIs(parsedQuery.Id)
                        .WhereIdNotIn(queryParams.IgnoredIds)
                        .WhereInUserCollection(queryParams.UserCollectionId)
                        .WherePublishDateIsBetween(parsedQuery.PublishedAfter, parsedQuery.PublishedBefore)
                        .WhereHasScore(queryParams.MinScore)
                        .WhereCreateDateIsWithin(queryParams.TimeFilter)
                        .WhereHasPV(queryParams.OnlyWithPVs)
                        .WhereMatchFilters(queryParams.AdvancedFilters);

            return(query);
        }
Esempio n. 9
0
        public ActionResult ByName(string query, ContentLanguagePreference?lang, int?start, int?maxResults, NameMatchMode?nameMatchMode,
                                   bool includeAlbums = true, bool includeArtists = true, bool includeNames = true, bool includePVs = false, bool includeTags = true, bool includeWebLinks = false,
                                   string callback    = null, DataFormat format   = DataFormat.Auto)
        {
            var param = new SongQueryParams(query, new SongType[] {}, 0, defaultMax, false, true, NameMatchMode.Exact, SongSortRule.Name, true, false, new int[] {});

            if (start.HasValue)
            {
                param.Paging.Start = start.Value;
            }

            if (maxResults.HasValue)
            {
                param.Paging.MaxEntries = Math.Min(maxResults.Value, defaultMax);
            }

            if (nameMatchMode.HasValue)
            {
                param.Common.NameMatchMode = nameMatchMode.Value;
            }

            var songs = Service.Find(s => new SongForApiContract(s, null, lang ?? ContentLanguagePreference.Default, includeAlbums, includeArtists, includeNames, includePVs, includeTags, true, includeWebLinks), param);

            return(Object(songs, format, callback));
        }
Esempio n. 10
0
        public ActionResult ByName(string query, ContentLanguagePreference?lang, int?start, int?maxResults, NameMatchMode?nameMatchMode,
                                   string callback, DataFormat format = DataFormat.Auto)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(Object(new PartialFindResult <SongForApiContract>(), format, callback));
            }

            var param = new ArtistQueryParams(query, new ArtistType[] { }, 0, defaultMax, false, true, NameMatchMode.Exact, ArtistSortRule.Name, false);

            if (start.HasValue)
            {
                param.Paging.Start = start.Value;
            }

            if (maxResults.HasValue)
            {
                param.Paging.MaxEntries = Math.Min(maxResults.Value, defaultMax);
            }

            if (nameMatchMode.HasValue)
            {
                param.Common.NameMatchMode = nameMatchMode.Value;
            }

            var songs = Service.FindArtists(s => new ArtistForApiContract(s, lang ?? ContentLanguagePreference.Default), param);

            return(Object(songs, format, callback));
        }
Esempio n. 11
0
 public ArtistSearchTextQuery OverrideMatchMode(NameMatchMode?matchMode)
 {
     return(matchMode.HasValue ? new ArtistSearchTextQuery(Query, matchMode.Value, OriginalQuery, _words) : this);
 }
Esempio n. 12
0
        private void TestGetMatchModeAndQueryForSearch(string query, string expectedQuery, NameMatchMode?expectedMode = null, NameMatchMode originalMode = NameMatchMode.Auto)
        {
            var result = FindHelpers.GetMatchModeAndQueryForSearch(query, ref originalMode);

            result.Should().Be(expectedQuery, "query");
            if (expectedMode != null)
            {
                originalMode.Should().Be(expectedMode, "matchMode");
            }
        }
Esempio n. 13
0
        private void TestGetMatchModeAndQueryForSearch(string query, string expectedQuery, NameMatchMode?expectedMode = null, NameMatchMode originalMode = NameMatchMode.Auto)
        {
            var result = FindHelpers.GetMatchModeAndQueryForSearch(query, ref originalMode);

            Assert.AreEqual(expectedQuery, result, "query");
            if (expectedMode != null)
            {
                Assert.AreEqual(expectedMode, originalMode, "matchMode");
            }
        }