Example #1
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);
        }
Example #2
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);
        }