Exemplo n.º 1
0
        public static ElasticBeatmap GetElasticBeatmap(BeatmapSet bmSet)
        {
            var bm = new ElasticBeatmap
            {
                Id           = bmSet.SetId,
                Artist       = bmSet.Artist,
                Creator      = bmSet.Creator,
                RankedStatus = bmSet.RankedStatus,
                Mode         = bmSet.ChildrenBeatmaps.Select(cb => cb.Mode).ToList(),
                Tags         = bmSet.Tags.Split(" ").Where(x => !string.IsNullOrWhiteSpace(x)).ToList(),
                Title        = bmSet.Title,
                DiffName     = bmSet.ChildrenBeatmaps.Select(cb => cb.DiffName).ToList(),
                ApprovedDate =
                    bmSet.ApprovedDate?.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds ?? 0
            };

            return(bm);
        }
Exemplo n.º 2
0
        private void rIndexBeatmap(BeatmapSet set)
        {
            if (xi++ % 10000 == 0)
            {
                Logger.LogPrint($"Index ElasticBeatmap of Id {set.SetId}");
            }

            _elasticClient.DeleteByQuery <ElasticBeatmap>(
                x =>
                x.Query(query => query.Exists(exists => exists.Field(field => field.Id == set.SetId)))
                );
            var map = ElasticBeatmap.GetElasticBeatmap(set);

            //Logger.LogPrint($"Index ElasticBeatmap of Id {set.SetId}");

            var result = _elasticClient.IndexDocument(map);

            if (!result.IsValid)
            {
                Logger.LogPrint(result.DebugInformation, LoggingTarget.Network, LogLevel.Important);
            }
        }