public void SetUp() { queryParams = new SongQueryParams { SortRule = SongSortRule.Name }; context = new DatabaseTestContext <IQuerySource>(); }
public void SetUp() { querySource = new QuerySourceList(); artist = new Artist(TranslatedString.Create("Junk")) { Id = 257 }; song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = 121, SongType = SongType.Original, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; AddSong(song); songWithArtist = new Song(new LocalizedString("Crystal Tears", ContentLanguageSelection.English)) { Id = 7787, FavoritedTimes = 39, CreateDate = new DateTime(2012, 1, 1) }; songWithArtist.AddArtist(artist); AddSong(songWithArtist); queryParams = new SongQueryParams(); search = new Model.Service.Search.SongSearch.SongSearch(querySource, ContentLanguagePreference.Default); }
public FeedResult Feed(IndexRouteParams indexParams) { WebHelper.VerifyUserAgent(Request); var pageSize = (indexParams.pageSize.HasValue ? Math.Min(indexParams.pageSize.Value, 30) : 30); var sortRule = indexParams.sort ?? SongSortRule.Name; var timeFilter = DateTimeUtils.ParseFromSimpleString(indexParams.since); var filter = indexParams.filter; var songType = indexParams.songType ?? SongType.Unspecified; var draftsOnly = indexParams.draftsOnly ?? false; var matchMode = indexParams.matchMode ?? NameMatchMode.Auto; var onlyWithPVs = indexParams.onlyWithPVs ?? false; var minScore = indexParams.minScore ?? 0; var queryParams = new SongQueryParams(filter, songType != SongType.Unspecified ? new[] { songType } : new SongType[] { }, 0, pageSize, draftsOnly, false, matchMode, sortRule, false, false, null) { TimeFilter = timeFilter, OnlyWithPVs = onlyWithPVs, ArtistId = indexParams.artistId ?? 0, MinScore = minScore, }; var result = Service.FindWithThumbPreferNotNico(queryParams); var fac = new SongFeedFactory(); var feed = fac.Create(result.Items, VocaUriBuilder.CreateAbsolute(Url.Action("Index", indexParams)), song => RenderPartialViewToString("SongItem", song), song => Url.Action("Details", new { id = song.Id })); return(new FeedResult(new Atom10FeedFormatter(feed))); }
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)); }
public void SetUp() { _queryParams = new SongQueryParams { SortRule = SongSortRule.Name }; _entryUrlParser = new EntryUrlParser(); _context = new DatabaseTestContext <IDatabaseContext>(); }
public void QueryNameMoveExactToTop() { _queryParams = _queryParams with { Common = _queryParams.Common with { TextQuery = SearchTextQuery.Create("Tears"), MoveExactToTop = true, },
public PartialFindResult <SongForApiContract> GetList( string query = "", string songTypes = null, [FromUri] string[] tagName = null, [FromUri] int[] tagId = null, bool childTags = false, [FromUri] int[] artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool includeMembers = false, bool onlyWithPvs = false, [FromUri] PVServices?pvServices = null, int?since = null, int?minScore = null, int?userCollectionId = null, int?releaseEventId = null, EntryStatus?status = null, [FromUri] AdvancedSearchFilter[] advancedFilters = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <SongType> .ParseMultiple(songTypes); var param = new SongQueryParams(textQuery, types, start, Math.Min(maxResults, absoluteMax), getTotalCount, sort, false, preferAccurateMatches, null) { ArtistParticipation = { ArtistIds = artistId, Participation = artistParticipationStatus, ChildVoicebanks = childVoicebanks, IncludeMembers = includeMembers }, TagIds = tagId, Tags = tagName, ChildTags = childTags, OnlyWithPVs = onlyWithPvs, TimeFilter = since.HasValue ? TimeSpan.FromHours(since.Value) : TimeSpan.Zero, MinScore = minScore ?? 0, PVServices = pvServices, UserCollectionId = userCollectionId ?? 0, ReleaseEventId = releaseEventId ?? 0, AdvancedFilters = advancedFilters, LanguagePreference = lang }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
public PartialFindResult <T> Find <T>(Func <Song, T> fac, SongQueryParams queryParams) where T : class { return(HandleQuery(session => { var result = Find(session, queryParams); return new PartialFindResult <T>(result.Items.Select(fac).ToArray(), result.TotalCount, result.Term); })); }
public void ListSortName() { _queryParams = _queryParams with { SortRule = SongSortRule.Name }; var result = CallFind(); result.Items.Length.Should().Be(7, "Number of results"); result.TotalCount.Should().Be(7, "Total result count"); result.Items[0].DefaultName.Should().Be("Azalea"); result.Items[1].DefaultName.Should().Be("Crystal Tears"); }
public void QueryNameWords() { _queryParams = _queryParams with { Common = _queryParams.Common with { TextQuery = SearchTextQuery.Create("Tears Crystal", NameMatchMode.Words) } }; var result = CallFind(); result.Items.Length.Should().Be(1, "1 result"); result.TotalCount.Should().Be(1, "total result count"); result.Items[0].DefaultName.Should().Be("Crystal Tears"); }
public void ListSkip() { _queryParams = _queryParams with { Paging = _queryParams.Paging with { Start = 1 } }; var result = CallFind(); result.Items.Length.Should().Be(6, "Number of results"); result.TotalCount.Should().Be(7, "Total result count"); AssertHasSong(result, Db.Song); }
public void ListSortAdditionDate() { _queryParams = _queryParams with { SortRule = SongSortRule.AdditionDate }; var result = CallFind(); result.Items.Length.Should().Be(7, "Number of results"); result.TotalCount.Should().Be(7, "Total result count"); result.Items[0].DefaultName.Should().Be("Nebula"); result.Items[1].DefaultName.Should().Be("Tears of Palm"); result.Items[2].DefaultName.Should().Be("Crystal Tears"); }
public PartialViewResult SongsPaged(int id = invalidId, int?page = null) { var pageIndex = (page - 1) ?? 0; var queryParams = new SongQueryParams { Paging = PagingProperties.CreateFromPage(pageIndex, entriesPerPage, true), SortRule = SongSortRule.Name, ArtistId = id }; var result = Services.Songs.Find(queryParams); var data = new PagingData <SongContract>(result.Items.ToPagedList(pageIndex, entriesPerPage, result.TotalCount), id, "SongsPaged", "ui-tabs-3"); return(PartialView("PagedSongs", data)); }
public void QueryNamePartial() { _queryParams = _queryParams with { Common = _queryParams.Common with { TextQuery = SearchTextQuery.Create("Tears", NameMatchMode.Partial) } }; var result = CallFind(); result.Items.Length.Should().Be(3, "Number of results"); result.TotalCount.Should().Be(3, "total result count"); AssertHasSong(result, Db.Song2); AssertHasSong(result, Db.Song3); AssertHasSong(result, Db.Song6); }
public PartialFindResult <SongForApiContract> GetList( string query = "", string songTypes = null, string tag = null, int?artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool onlyWithPvs = false, [FromUri] PVServices?pvServices = null, int?since = null, int?minScore = null, [FromUri] ContentLanguageSelections?lyrics = null, int?userCollectionId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <SongType> .ParseMultiple(songTypes); var param = new SongQueryParams(textQuery, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, sort, false, preferAccurateMatches, null) { Tag = tag, OnlyWithPVs = onlyWithPvs, ArtistId = artistId ?? 0, ArtistParticipationStatus = artistParticipationStatus, ChildVoicebanks = childVoicebanks, TimeFilter = since.HasValue ? TimeSpan.FromHours(since.Value) : TimeSpan.Zero, LyricsLanguages = lyrics != null?lyrics.Value.ToIndividualSelections().ToArray() : null, MinScore = minScore ?? 0, PVServices = pvServices, UserCollectionId = userCollectionId ?? 0 }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
public ActionResult Index(IndexRouteParams indexParams) { WebHelper.VerifyUserAgent(Request); var pageSize = (indexParams.pageSize.HasValue ? Math.Min(indexParams.pageSize.Value, 30) : 30); var page = indexParams.page ?? 1; var sortRule = indexParams.sort ?? SongSortRule.Name; var timeFilter = DateTimeUtils.ParseFromSimpleString(indexParams.since); var filter = indexParams.filter; var songType = indexParams.songType ?? SongType.Unspecified; var draftsOnly = indexParams.draftsOnly ?? false; var matchMode = indexParams.matchMode ?? NameMatchMode.Auto; var onlyWithPVs = indexParams.onlyWithPVs ?? false; var view = indexParams.view ?? SongViewMode.Details; if (matchMode == NameMatchMode.Auto && filter != null && filter.Length <= 2) { matchMode = NameMatchMode.StartsWith; } var queryParams = new SongQueryParams(filter, songType != SongType.Unspecified ? new[] { songType } : new SongType[] { }, (page - 1) * pageSize, pageSize, draftsOnly, true, matchMode, sortRule, false, false, null) { TimeFilter = timeFilter, OnlyWithPVs = onlyWithPVs, ArtistId = indexParams.artistId ?? 0 }; var result = Service.FindWithAlbum(queryParams, view == SongViewMode.Preview); if (page == 1 && result.TotalCount == 1 && result.Items.Length == 1) { return(RedirectToAction("Details", new { id = result.Items[0].Id })); } SetSearchEntryType(EntryType.Song); var model = new Index(result, filter, matchMode, songType, indexParams.since, onlyWithPVs, sortRule, view, draftsOnly, page, pageSize, indexParams); return(View(model)); }
public async Task <FeedResult> Feed(IndexRouteParams indexParams) { WebHelper.VerifyUserAgent(Request); var pageSize = (indexParams.pageSize.HasValue ? Math.Min(indexParams.pageSize.Value, 30) : 30); var sortRule = indexParams.sort ?? SongSortRule.Name; var timeFilter = DateTimeUtils.ParseFromSimpleString(indexParams.since); var filter = indexParams.filter; var songType = indexParams.songType ?? SongType.Unspecified; var matchMode = indexParams.matchMode ?? NameMatchMode.Auto; var onlyWithPVs = indexParams.onlyWithPVs ?? false; var minScore = indexParams.minScore ?? 0; var textQuery = SearchTextQuery.Create(filter, matchMode); var queryParams = new SongQueryParams(textQuery, songType != SongType.Unspecified ? new[] { songType } : new SongType[] { }, 0, pageSize, false, sortRule, false, false, null) { ArtistParticipation = { ArtistIds = !indexParams.artistId.HasValue || indexParams.artistId.Value == 0 ? null : new [] { indexParams.artistId.Value } }, TimeFilter = timeFilter, OnlyWithPVs = onlyWithPVs, MinScore = minScore, UserCollectionId = indexParams.userCollectionId ?? 0, FollowedByUserId = indexParams.followedByUserId ?? 0 }; var result = Service.FindWithThumbPreferNotNico(queryParams); var fac = new SongFeedFactory(); var feed = await fac.CreateAsync(result.Items, VocaUriBuilder.CreateAbsolute(Url.Action("Index", indexParams)), song => RenderPartialViewToStringAsync("SongItem", song), song => Url.Action("Details", new { id = song.Id })); return(new FeedResult(new Atom10FeedFormatter(feed))); }
public PartialFindResult <SongForApiContract> GetList( string query = "", SongType songTypes = SongType.Unspecified, string tag = null, int?artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool onlyWithPvs = false, int?since = null, [FromUri] ContentLanguageSelections?lyrics = null, int?userCollectionId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var types = songTypes != SongType.Unspecified ? new[] { songTypes } : new SongType[0]; var param = new SongQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false, false, null) { Tag = tag, OnlyWithPVs = onlyWithPvs, ArtistId = artistId ?? 0, ArtistParticipationStatus = artistParticipationStatus, ChildVoicebanks = childVoicebanks, TimeFilter = since.HasValue ? TimeSpan.FromHours(since.Value) : TimeSpan.Zero, LyricsLanguages = lyrics != null?lyrics.Value.ToIndividualSelections().ToArray() : null, UserCollectionId = userCollectionId ?? 0 }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
private PartialFindResult <Song> Find(ISession session, SongQueryParams queryParams) { return(new SongSearch(new NHibernateDatabaseContext(session, PermissionContext), queryParams.LanguagePreference, _entryUrlParser).Find(queryParams)); }
private PartialFindResult <Song> Find(ISession session, SongQueryParams queryParams) { return(new SongSearch(new QuerySourceSession(session), LanguagePreference, entryUrlParser).Find(queryParams)); }
public PartialFindResult <SongContract> Find(SongQueryParams queryParams) { return(Find(s => new SongContract(s, PermissionContext.LanguagePreference), queryParams)); }
public PartialFindResult <SongWithAlbumAndPVsContract> FindWithAlbum(SongQueryParams queryParams, bool getPVs) { return(Find(s => new SongWithAlbumAndPVsContract(s, PermissionContext.LanguagePreference, getPVs), queryParams)); }
public PartialFindResult <SongContract> FindWithThumbPreferNotNico(SongQueryParams queryParams) { return(Find(s => new SongContract(s, PermissionContext.LanguagePreference, VideoServiceHelper.GetThumbUrlPreferNotNico(s.PVs.PVs)), queryParams)); }