Пример #1
0
        public static SortDefinition <T> BuildSort <T>(this ODataUriParser query, PropertyCalculator propertyCalculator = null)
        {
            var orderBy = query.ParseOrderBy();

            if (orderBy != null)
            {
                var sorts = new List <SortDefinition <T> >();

                while (orderBy != null)
                {
                    sorts.Add(OrderBy <T>(orderBy, propertyCalculator));

                    orderBy = orderBy.ThenBy;
                }

                if (sorts.Count > 1)
                {
                    return(Builders <T> .Sort.Combine(sorts));
                }
                else
                {
                    return(sorts[0]);
                }
            }

            return(null);
        }
Пример #2
0
        public override void selectProperties()
        {
            var gameTimeInMinutes = (_matchStats.gameDuration / 60);
            var matchStats        = _matchStats.stats;

            PropertyCalculator kda = new PropertyCalculator(matchStats.kda);

            setPropertyReferenceValues(kda, 0.5f, 2f, 0.3f);

            PropertyCalculator visionScorePerMinute = new PropertyCalculator(matchStats.visionScore / gameTimeInMinutes);

            setPropertyReferenceValues(visionScorePerMinute, 1f, 3f, 1f);

            PropertyCalculator totalHeal = new PropertyCalculator(matchStats.totalHeal / gameTimeInMinutes);

            setPropertyReferenceValues(totalHeal, 3f, 6f, 0.3f);

            PropertyCalculator timeCCingOthers = new PropertyCalculator(matchStats.timeCCingOthers / gameTimeInMinutes);

            setPropertyReferenceValues(timeCCingOthers, 0.5f, 2f, 0.5f);

            _propertiesList.Add(kda);
            _propertiesList.Add(visionScorePerMinute);
            _propertiesList.Add(totalHeal);
            _propertiesList.Add(timeCCingOthers);
        }
Пример #3
0
        public static SortDefinition <T> OrderBy <T>(OrderByClause clause, PropertyCalculator propertyCalculator = null)
        {
            var propertyName = clause.Expression.BuildFieldDefinition <T>(propertyCalculator);

            if (clause.Direction == OrderByDirection.Ascending)
            {
                return(Builders <T> .Sort.Ascending(propertyName));
            }
            else
            {
                return(Builders <T> .Sort.Descending(propertyName));
            }
        }
        public override void selectProperties()
        {
            PropertyCalculator kda = new PropertyCalculator(_matchStats.stats.kda);

            setPropertyReferenceValues(kda, 0.5f, 5f, 1f);

            PropertyCalculator damageDealtByMinute = new PropertyCalculator(_matchStats.stats.totalDamageDealtToChampions / (_matchStats.gameDuration / 60));

            setPropertyReferenceValues(damageDealtByMinute, 200f, 1500f, 0.7f);

            float deaths = _matchStats.stats.deaths;
            float damageTakenByDeathValue          = (deaths > 0 ? _matchStats.stats.totalDamageTaken / deaths : _matchStats.stats.totalDamageTaken);
            PropertyCalculator damageTakenPerDeath = new PropertyCalculator(damageTakenByDeathValue);

            setPropertyReferenceValues(damageTakenPerDeath, 2000f, 6000f, 0.3f);

            _propertiesList.Add(kda);
            _propertiesList.Add(damageDealtByMinute);
            _propertiesList.Add(damageTakenPerDeath);
        }
Пример #5
0
        public override void selectProperties()
        {
            var gameTimeInMinutes = (_matchStats.gameDuration / 60);
            var matchStats        = _matchStats.stats;

            PropertyCalculator kda = new PropertyCalculator(matchStats.kda);

            setPropertyReferenceValues(kda, 0.5f, 5f, 1f);

            PropertyCalculator damageDealtByMinute = new PropertyCalculator(matchStats.totalDamageDealtToChampions / gameTimeInMinutes);

            setPropertyReferenceValues(damageDealtByMinute, 200f, 1500f, 0.7f);

            PropertyCalculator goldEarned = new PropertyCalculator(matchStats.goldEarned / gameTimeInMinutes);

            setPropertyReferenceValues(goldEarned, 200f, 500f, 0.4f);

            _propertiesList.Add(kda);
            _propertiesList.Add(damageDealtByMinute);
            _propertiesList.Add(goldEarned);
        }
        public override void selectProperties()
        {
            var gameTimeInMinutes = (_matchStats.gameDuration / 60);
            var matchStats        = _matchStats.stats;

            PropertyCalculator kda = new PropertyCalculator(matchStats.kda);

            setPropertyReferenceValues(kda, 0.5f, 5f, 0.7f);

            PropertyCalculator damageDealtToObjectivesByMinute = new PropertyCalculator(matchStats.damageDealtToObjectives / gameTimeInMinutes);

            setPropertyReferenceValues(damageDealtToObjectivesByMinute, 200f, 800f, 0.9f);

            PropertyCalculator minionsKilledByMinute = new PropertyCalculator(matchStats.totalMinionsKilled / gameTimeInMinutes);

            setPropertyReferenceValues(minionsKilledByMinute, 5f, 10f, 1f);

            _propertiesList.Add(kda);
            _propertiesList.Add(damageDealtToObjectivesByMinute);
            _propertiesList.Add(minionsKilledByMinute);
        }
Пример #7
0
        public override void selectProperties()
        {
            var gameTimeInMinutes = (_matchStats.gameDuration / 60);
            var matchStats        = _matchStats.stats;

            PropertyCalculator kda = new PropertyCalculator(matchStats.kda);

            setPropertyReferenceValues(kda, 0.5f, 3f, 0.5f);

            PropertyCalculator visionScorePerMinute = new PropertyCalculator(matchStats.visionScore / gameTimeInMinutes);

            setPropertyReferenceValues(visionScorePerMinute, 0.5f, 2f, 0.7f);

            PropertyCalculator neutralMinionsKilledByMinute = new PropertyCalculator(matchStats.neutralMinionsKilled / gameTimeInMinutes);

            setPropertyReferenceValues(neutralMinionsKilledByMinute, 3f, 6f, 1f);

            _propertiesList.Add(kda);
            _propertiesList.Add(visionScorePerMinute);
            _propertiesList.Add(neutralMinionsKilledByMinute);
        }
        public override void selectProperties()
        {
            var gameTimeInMinutes = (_matchStats.gameDuration / 60);
            var matchStats        = _matchStats.stats;

            PropertyCalculator kda = new PropertyCalculator(matchStats.kda);

            setPropertyReferenceValues(kda, 0.5f, 3f, 0.6f);

            float deaths = _matchStats.stats.deaths;
            float damageTakenByDeathValue          = (deaths > 0 ? _matchStats.stats.totalDamageTaken / deaths : _matchStats.stats.totalDamageTaken);
            PropertyCalculator damageTakenPerDeath = new PropertyCalculator(damageTakenByDeathValue);

            setPropertyReferenceValues(damageTakenPerDeath, 2000f, 6000f, 0.5f);

            PropertyCalculator damageSelfMitigated = new PropertyCalculator(matchStats.damageSelfMitigated / gameTimeInMinutes);

            setPropertyReferenceValues(damageSelfMitigated, 700f, 2000f, 0.9f);

            _propertiesList.Add(kda);
            _propertiesList.Add(damageTakenPerDeath);
            _propertiesList.Add(damageSelfMitigated);
        }
Пример #9
0
        public static FilterDefinition <MongoContentEntity> BuildQuery(ODataUriParser query, Guid schemaId, Status[] status, PropertyCalculator propertyCalculator)
        {
            var filters = new List <FilterDefinition <MongoContentEntity> >
            {
                Filter.Eq(x => x.SchemaId, schemaId),
                Filter.In(x => x.Status, status),
                Filter.Eq(x => x.IsDeleted, false)
            };

            var filter = query.BuildFilter <MongoContentEntity>(propertyCalculator);

            if (filter.Filter != null)
            {
                if (filter.Last)
                {
                    filters.Add(filter.Filter);
                }
                else
                {
                    filters.Insert(0, filter.Filter);
                }
            }

            if (filters.Count == 1)
            {
                return(filters[0]);
            }
            else
            {
                return(Filter.And(filters));
            }
        }
Пример #10
0
        public static IFindFluent <MongoContentEntity, MongoContentEntity> ContentSort(this IFindFluent <MongoContentEntity, MongoContentEntity> cursor, ODataUriParser query, PropertyCalculator propertyCalculator)
        {
            var sort = query.BuildSort <MongoContentEntity>(propertyCalculator);

            return(sort != null?cursor.Sort(sort) : cursor.SortByDescending(x => x.LastModified));
        }
Пример #11
0
 public static (FilterDefinition <T> Filter, bool Last) BuildFilter <T>(this ODataUriParser query, PropertyCalculator propertyCalculator = null, bool supportsSearch = true)
 {
Пример #12
0
        public static FilterDefinition <T> Visit(QueryNode node, PropertyCalculator propertyCalculator)
        {
            var visitor = new FilterVisitor <T>(propertyCalculator);

            return(node.Accept(visitor));
        }
Пример #13
0
 private FilterVisitor(PropertyCalculator propertyCalculator)
 {
     this.propertyCalculator = propertyCalculator;
 }
Пример #14
0
 public void setPropertyReferenceValues(PropertyCalculator property, float min, float max, float weight)
 {
     property.referenceMinValue = min;
     property.referenceMaxValue = max;
     property.referenceWeight   = weight;
 }
Пример #15
0
        public static StringFieldDefinition <T, object> BuildFieldDefinition <T>(this QueryNode node, PropertyCalculator propertyCalculator)
        {
            propertyCalculator = propertyCalculator ?? DefaultCalculator;

            var propertyParts = node.Accept(PropertyNameVisitor.Instance).ToArray();
            var propertyName  = propertyCalculator(propertyParts);

            return(new StringFieldDefinition <T, object>(propertyName));
        }