[longomatch] Add filters to the project stats



commit 68309a88e672379c7bb90de1ee28655a89a0a035
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Sep 28 18:22:15 2013 +0200

    Add filters to the project stats

 LongoMatch.Core/Stats/ProjectStats.cs |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/LongoMatch.Core/Stats/ProjectStats.cs b/LongoMatch.Core/Stats/ProjectStats.cs
index 6debf46..79aa31a 100644
--- a/LongoMatch.Core/Stats/ProjectStats.cs
+++ b/LongoMatch.Core/Stats/ProjectStats.cs
@@ -30,10 +30,13 @@ namespace LongoMatch.Stats
        {
                List<CategoryStats> catStats;
                GameUnitsStats guStats;
+               PlaysFilter filter;
+               Project project;
                
                public ProjectStats (Project project)
                {
                        catStats = new List<CategoryStats>();
+                       this.project = project;
                        
                        ProjectName = project.Description.Title;
                        Date = project.Description.MatchDate;
@@ -42,8 +45,8 @@ namespace LongoMatch.Stats
                        Competition = project.Description.Competition;
                        Season = project.Description.Season;
                        Results = String.Format("{0}-{1}", project.Description.LocalGoals, 
project.Description.VisitorGoals);
-                       UpdateStats (project);
-                       UpdateGameUnitsStats (project);
+                       UpdateStats ();
+                       UpdateGameUnitsStats ();
                }
                
                public void Dispose () {
@@ -114,7 +117,14 @@ namespace LongoMatch.Stats
                        }
                }
                
-               void UpdateGameUnitsStats (Project project) {
+               public PlaysFilter Filter {
+                       set {
+                               filter = value;
+                               UpdateStats ()
+                       }
+               }
+               
+               void UpdateGameUnitsStats () {
                        guStats = new GameUnitsStats(project.GameUnits, (int)project.Description.File.Length);
                }
                
@@ -123,7 +133,7 @@ namespace LongoMatch.Stats
                        visitorTeamCount = plays.Where(p => p.Team == Team.VISITOR || p.Team == 
Team.BOTH).Count();
                }
 
-               void UpdateStats (Project project) {
+               void UpdateStats () {
                        catStats.Clear();
                        
                        Field = project.Categories.FieldBackground;
@@ -135,7 +145,10 @@ namespace LongoMatch.Stats
                                List<Play> plays, homePlays, awayPlays;
                                int localTeamCount, visitorTeamCount;
                                
-                               plays = project.PlaysInCategory (cat);
+                               plays = project.PlaysInCategory (cat).Where;
+                               if (filter != null) {
+                                       plays = plays.Where(p => filter.IsVisible (p));
+                               }
                                homePlays =plays.Where(p => p.Team == Team.LOCAL || p.Team == 
Team.BOTH).ToList();
                                awayPlays =plays.Where(p => p.Team == Team.VISITOR || p.Team == 
Team.BOTH).ToList();
                                stats = new CategoryStats(cat, plays.Count, homePlays.Count(), 
awayPlays.Count());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]