Example #1
0
        public DataQualityReport GetDataQualityReport(OCM.API.Common.Model.ChargePoint poi)
        {
            DataQualityReport report = new DataQualityReport();

            report.POIReports.Add(CheckPOIDataQuality(poi));
            return(report);
        }
Example #2
0
        /// <summary>
        /// For given POI, return data quality report and supporting analysis results
        /// </summary>
        /// <param name="poi"></param>
        /// <returns></returns>
        public POIDataQualityReport CheckPOIDataQuality(OCM.API.Common.Model.ChargePoint poi)
        {
            var report = new POIDataQualityReport();

            report.POI = poi;

            DateTime recentUpdateThreshold = DateTime.UtcNow.AddMonths(-6);

            if (
                (poi.DateLastConfirmed.HasValue && !(poi.DateLastConfirmed.Value > recentUpdateThreshold))
                ||
                (poi.UserComments != null && poi.UserComments.Any(u => u.CheckinStatusType != null && u.CheckinStatusType.IsPositive == true && u.DateCreated > recentUpdateThreshold))
                ||
                (poi.MediaItems != null && poi.MediaItems.Any(u => u.DateCreated > recentUpdateThreshold))
                )
            {
                //has either a recent datelastconfirmed value or a recent positive checkin
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "User Feedback", Comment = "Has recent user verification", IsPositive = true
                });
            }
            else
            {
                //low quality score for date last confirmed
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 10, Category = "User Feedback", Comment = "No recent user verification.", IsPositive = false
                });
            }

            if (poi.UserComments == null || (poi.UserComments != null && !poi.UserComments.Any()))
            {
                //low quality score for comments
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 10, Category = "User Feedback", Comment = "No comments or check-ins", IsPositive = false
                });
            }
            else
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "User Feedback", Comment = "Has comments or check-ins", IsPositive = true
                });
            }

            if (poi.MediaItems == null || (poi.MediaItems != null && !poi.MediaItems.Any()))
            {
                //low quality score for photos
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 10, Category = "User Feedback", Comment = "No photos", IsPositive = false
                });
            }
            else
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "User Feedback", Comment = "Has photos", IsPositive = true
                });
            }

            if (poi.UsageTypeID == null || (poi.UsageTypeID != null && poi.UsageType.ID == 0))
            {
                //low quality score for usage type
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 10, Category = "Data Completeness", Comment = "Unknown Usage Type", IsPositive = false
                });
            }
            else
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "Data Completeness", Comment = "Usage Type Known", IsPositive = true
                });
            }
            if (poi.StatusType == null || (poi.StatusType != null && poi.StatusType.ID == 0))
            {
                //low quality score for status type
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 10, Category = "Data Completeness", Comment = "Unknown Operational Status", IsPositive = false
                });
            }
            else
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "Data Completeness", Comment = "Operational Status Known", IsPositive = true
                });
            }

            if (poi.Connections == null || !poi.Connections.Any())
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Weighting = 50, Category = "Data Completeness", Comment = "No Equipment Details", IsPositive = false
                });
            }
            else
            {
                report.ReportItems.Add(new DataQualityReportItem {
                    Category = "Data Completeness", Comment = "Equipment Details Present", IsPositive = true
                });
            }

            //data quality score starts at 5 (excellent) and is reduced towards 0 for each data issue

            double totalPoints = 100;

            foreach (var p in report.ReportItems.Where(r => r.IsPositive == false))
            {
                totalPoints -= p.Weighting;
            }
            if (totalPoints < 0)
            {
                totalPoints = 0;
            }
            report.DataQualityScore = totalPoints;

            return(report);
        }