예제 #1
0
        /// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param>
        /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param>
        /// <param name="start">0-based order number of the first item to be returned.</param>
        /// <param name="maxResults">Maximum number of results to be returned.</param>
        /// <param name="draftsOnly">Whether to return only entries with a draft status.</param>
        /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param>
        /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param>
        /// <param name="sortRule">Sort rule for results.</param>
        /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param>
        public ArtistQueryParams(string query, ArtistType[] songTypes, int start, int maxResults,
            bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode, ArtistSortRule sortRule, bool moveExactToTop)
        {
            Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, true, moveExactToTop);
            Paging = new PagingProperties(start, maxResults, getTotalCount);

            ArtistTypes = songTypes ?? new ArtistType[] { };
            SortRule = sortRule;
        }
        public static IQueryable<Artist> OrderByArtistRule(this IQueryable<Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule) {
                case ArtistSortRule.Name:
                    return FindHelpers.AddNameOrder(criteria, languagePreference);
                case ArtistSortRule.AdditionDate:
                    return criteria.OrderByDescending(a => a.CreateDate);
            }

            return criteria;
        }
예제 #3
0
        public ArtistIndex(PartialFindResult<ArtistWithAdditionalNamesContract> result, string filter,
            ArtistType artistType, bool? draftsOnly, ArtistSortRule sort, int? page, IndexRouteParams routeParams)
        {
            Artists = new StaticPagedList<ArtistWithAdditionalNamesContract>(result.Items, page ?? 1, 30, result.TotalCount);
            DraftsOnly = draftsOnly ?? false;
            Filter = filter;
            ArtistType = artistType;
            Sort = sort;
            RouteParams = routeParams;

            FilterableArtistTypes = EnumVal<ArtistType>.Values.ToDictionary(a => a, Translate.ArtistTypeName);
        }
		public static IQueryable<Artist> OrderBy(
			this IQueryable<Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference) {

			switch (sortRule) {
				case ArtistSortRule.Name:
					return FindHelpers.AddNameOrder(criteria, languagePreference);
				case ArtistSortRule.AdditionDate:
					return criteria.OrderByDescending(a => a.CreateDate);
				case ArtistSortRule.AdditionDateAsc:
					return criteria.OrderBy(a => a.CreateDate);
				case ArtistSortRule.SongCount:
					return criteria.OrderByDescending(a => a.AllSongs.Count());
				case ArtistSortRule.SongRating:
					return criteria.OrderByDescending(a => a.AllSongs
						.Where(s => !s.Song.Deleted)
						.Sum(s => s.Song.RatingScore));
			}

			return criteria;

		}
예제 #5
0
        public PartialFindResult <ArtistForApiContract> GetList(
            string query             = "",
            string artistTypes       = null,
            bool allowBaseVoicebanks = true,
            [FromQuery(Name = "tagName[]")] string[] tagName = null,
            [FromQuery(Name = "tagId[]")] int[] tagId        = null,
            bool childTags       = false,
            int?followedByUserId = null,
            EntryStatus?status   = null,
            [FromQuery(Name = "advancedFilters")] AdvancedSearchFilterParams[] advancedFilters = null,
            int start                      = 0, int maxResults = DefaultMax, bool getTotalCount = false,
            ArtistSortRule sort            = ArtistSortRule.Name,
            bool preferAccurateMatches     = false,
            NameMatchMode nameMatchMode    = NameMatchMode.Exact,
            ArtistOptionalFields fields    = ArtistOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var textQuery = ArtistSearchTextQuery.Create(query, nameMatchMode);
            var types     = EnumVal <ArtistType> .ParseMultiple(artistTypes);

            var param = new ArtistQueryParams(textQuery, types, start, Math.Min(maxResults, AbsoluteMax), getTotalCount, sort, preferAccurateMatches)
            {
                Tags                = tagName,
                TagIds              = tagId,
                ChildTags           = childTags,
                UserFollowerId      = followedByUserId ?? 0,
                AllowBaseVoicebanks = allowBaseVoicebanks,
                AdvancedFilters     = advancedFilters?.Select(advancedFilter => advancedFilter.ToAdvancedSearchFilter()).ToArray(),
            };

            param.Common.EntryStatus = status;

            var artists = _service.FindArtists(s => new ArtistForApiContract(s, lang, _thumbPersister, fields), param);

            return(artists);
        }
예제 #6
0
        public static IQueryable <Artist> OrderByArtistRule(this IQueryable <Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule)
            {
            case ArtistSortRule.Name:
                return(FindHelpers.AddNameOrder(criteria, languagePreference));

            case ArtistSortRule.AdditionDate:
                return(criteria.OrderByDescending(a => a.CreateDate));
            }

            return(criteria);
        }
예제 #7
0
 public static IQueryable <T> OrderBy <T>(
     this IQueryable <T> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference) where T : IArtistLink => sortRule switch
 {
예제 #8
0
 public static IQueryable <Artist> OrderBy(
     this IQueryable <Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference) => sortRule switch
 {
예제 #9
0
        private IQueryOver <Artist, Artist> AddOrder(IQueryOver <Artist, Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule)
            {
            case ArtistSortRule.Name:
                return(FindHelpers.AddNameOrder(criteria, languagePreference));

            case ArtistSortRule.AdditionDate:
                return(criteria.OrderBy(a => a.CreateDate).Desc);
            }

            return(criteria);
        }
예제 #10
0
        /// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param>
        /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param>
        /// <param name="start">0-based order number of the first item to be returned.</param>
        /// <param name="maxResults">Maximum number of results to be returned.</param>
        /// <param name="draftsOnly">Whether to return only entries with a draft status.</param>
        /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param>
        /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param>
        /// <param name="sortRule">Sort rule for results.</param>
        /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param>
        public ArtistQueryParams(string query, ArtistType[] songTypes, int start, int maxResults,
                                 bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode, ArtistSortRule sortRule, bool moveExactToTop)
        {
            Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, true, moveExactToTop);
            Paging = new PagingProperties(start, maxResults, getTotalCount);

            ArtistTypes = songTypes ?? new ArtistType[] { };
            SortRule    = sortRule;
        }
예제 #11
0
        public PartialFindResult<ArtistForApiContract> GetList(
            string query = "",
            ArtistTypes artistTypes = ArtistTypes.Nothing,
            string tag = null,
            int? followedByUserId = null,
            EntryStatus? status = null,
            int start = 0, int maxResults = defaultMax, bool getTotalCount = false,
            ArtistSortRule sort = ArtistSortRule.Name,
            NameMatchMode nameMatchMode = NameMatchMode.Exact,
            ArtistOptionalFields fields = ArtistOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode);
            var types = ArtistHelper.GetArtistTypesFromFlags(artistTypes);

            var param = new ArtistQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false) {
                Tag = tag,
                UserFollowerId = followedByUserId ?? 0
            };
            param.Common.EntryStatus = status;

            var ssl = WebHelper.IsSSL(Request);
            var artists = service.FindArtists(s => new ArtistForApiContract(s, lang, thumbPersister, ssl, fields), param);

            return artists;
        }