Ejemplo n.º 1
0
        public IEnumerable <int?> SearchMovieIds(MovieSearchParams search)
        {
            if (string.IsNullOrEmpty(search.Search))
            {
                return(Enumerable.Empty <int?>());
            }

            using (var sphinx = new DbSphinx())
            {
                var qb = new SphinxQueryBuilder("torronto_movies")
                         .SelectColumns("id")
                         .AddMatch(string.Format("@!(description) {0}", EscapeUserInput(search.Search)))
                         .AddLimits(0, 100);

                if (search.MovieStatus > MovieStatus.Unknown)
                {
                    qb.AddWhere("status", (int)search.MovieStatus);
                }

                var items = sphinx.Query <int?>(qb.Build())
                            .ToList();

                return(items);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <int?> SearchTorrentIds(TorrentSearchParams search)
        {
            if (string.IsNullOrEmpty(search.Search))
            {
                return(Enumerable.Empty <int?>());
            }

            using (var sphinx = new DbSphinx())
            {
                var qb = new SphinxQueryBuilder("torronto_torrents")
                         .SelectColumns("id")
                         .SelectLiteral(string.Format("((video_quality & {0}) > 0) vq", (int)search.VideoQuality))
                         .SelectLiteral(string.Format("((sound_quality & {0}) > 0) aq", (int)search.AudioQuality))
                         .SelectLiteral(string.Format("((translation & {0}) > 0) tq", (int)search.TranslationQuality))
                         .AddMatch(EscapeUserInput(search.Search))
                         .AddLimits(0, 100);

                if (search.VideoQuality > VideoQuality.Unknown)
                {
                    qb.AddWhere("vq", 1);
                }
                if (search.AudioQuality > AudioQuality.Unknown)
                {
                    qb.AddWhere("aq", 1);
                }
                if (search.TranslationQuality > Translation.Unknown)
                {
                    qb.AddWhere("tq", 1);
                }

                var items = sphinx.Query <int?>(qb.Build())
                            .ToList();

                return(items);
            }
        }