public GetOverviewResult()
 {
     IncidentsPerApplication = new GetOverviewApplicationResult[0];
     TimeAxisLabels          = new string[0];
     StatSummary             = new OverviewStatSummary {
     };
 }
예제 #2
0
        private async Task GetStatSummary(GetApplicationOverview query, GetApplicationOverviewResult result)
        {
            using (var cmd = _unitOfWork.CreateDbCommand())
            {
                cmd.CommandText = @"select count(id) from incidents 
where CreatedAtUtc >= @minDate
AND ApplicationId = @appId 
AND Incidents.IgnoreReports = 0 
AND Incidents.IsSolved = 0;

select count(id) from errorreports 
where CreatedAtUtc >= @minDate
AND ApplicationId = @appId;

select count(distinct emailaddress) from IncidentFeedback
where CreatedAtUtc >= @minDate
AND ApplicationId = @appId
AND emailaddress is not null
AND DATALENGTH(emailaddress) > 0;

select count(*) from IncidentFeedback 
where CreatedAtUtc >= @minDate
AND ApplicationId = @appId
AND Description is not null
AND DATALENGTH(Description) > 0;";
                cmd.AddParameter("appId", query.ApplicationId);
                var minDate = query.NumberOfDays == 1
                    ? DateTime.Today.AddHours(DateTime.Now.Hour).AddHours(-23)
                    : DateTime.Today.AddDays(-query.NumberOfDays);
                cmd.AddParameter("minDate", minDate);

                using (var reader = await cmd.ExecuteReaderAsync())
                {
                    if (!await reader.ReadAsync())
                    {
                        throw new InvalidOperationException("Expected to be able to read.");
                    }

                    var data = new OverviewStatSummary();
                    data.Incidents = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Reports = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Followers = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.UserFeedback  = reader.GetInt32(0);
                    result.StatSummary = data;
                }
            }
        }
        private async Task GetStatSummary(GetOverview query, GetOverviewResult result)
        {
            using (var cmd = _unitOfWork.CreateDbCommand())
            {
                cmd.CommandText = $@"select count(id) from incidents 
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND Incidents.ApplicationId IN ({ApplicationIds})
AND Incidents.State <> {(int)IncidentState.Ignored} 
AND Incidents.State <> {(int)IncidentState.Closed};

select count(id) from errorreports 
where CreatedAtUtc >= @minDate
AND ApplicationId IN ({ApplicationIds})

select count(distinct emailaddress) from IncidentFeedback
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId IN ({ApplicationIds})
AND emailaddress is not null
AND DATALENGTH(emailaddress) > 0;

select count(*) from IncidentFeedback 
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId IN ({ApplicationIds})
AND Description is not null
AND DATALENGTH(Description) > 0;";

                var minDate = query.NumberOfDays == 1
                    ? StartDateForHours
                    : DateTime.Today.AddDays(-query.NumberOfDays);
                cmd.AddParameter("minDate", minDate);

                using (var reader = await cmd.ExecuteReaderAsync())
                {
                    if (!await reader.ReadAsync())
                    {
                        throw new InvalidOperationException("Expected to be able to read.");
                    }

                    var data = new OverviewStatSummary();
                    data.Incidents = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Reports = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Followers = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.UserFeedback  = reader.GetInt32(0);
                    result.StatSummary = data;
                }
            }
        }
예제 #4
0
        private async Task GetStatSummary(GetApplicationOverview query, GetApplicationOverviewResult result)
        {
            using (var cmd = _unitOfWork.CreateDbCommand())
            {
                if (!string.IsNullOrEmpty(query.Version))
                {
                    var versionId =
                        _unitOfWork.ExecuteScalar("SELECT Id FROM ApplicationVersions WHERE Version=@version",
                                                  new { version = query.Version });
                    cmd.CommandText = $@"select count(id) 
from incidents 
JOIN IncidentVersions ON (Incidents.Id = IncidentVersions.IncidentId)
WHERE IncidentVersions.VersionId = @versionId
AND CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId 
AND Incidents.State <> {(int)IncidentState.Ignored}
AND Incidents.State <> {(int)IncidentState.Closed};

SELECT count(id) from ErrorReports 
JOIN IncidentVersions ON (ErrorReports.IncidentId = IncidentVersions.IncidentId)
WHERE IncidentVersions.VersionId = @versionId
AND CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId;

SELECT count(distinct emailaddress) from IncidentFeedback
JOIN IncidentVersions ON (IncidentFeedback.IncidentId = IncidentVersions.IncidentId)
WHERE IncidentVersions.VersionId = @versionId
AND CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId
AND emailaddress is not null
AND DATALENGTH(emailaddress) > 0;

select count(*) from IncidentFeedback 
JOIN IncidentVersions ON (IncidentFeedback.IncidentId = IncidentVersions.IncidentId)
WHERE IncidentVersions.VersionId = @versionId
AND CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId
AND Description is not null
AND DATALENGTH(Description) > 0;";
                    cmd.AddParameter("versionId", versionId);
                }
                else
                {
                    cmd.CommandText = $@"select count(id) from incidents 
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId 
AND Incidents.State <> {(int)IncidentState.Ignored}
AND Incidents.State <> {(int)IncidentState.Closed};

select count(id) from ErrorReports 
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId;

select count(distinct emailaddress) from IncidentFeedback
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId
AND emailaddress is not null
AND DATALENGTH(emailaddress) > 0;

select count(*) from IncidentFeedback 
where CreatedAtUtc >= @minDate
AND CreatedAtUtc <= GetUtcDate()
AND ApplicationId = @appId
AND Description is not null
AND DATALENGTH(Description) > 0;";
                }
                cmd.AddParameter("appId", query.ApplicationId);
                var minDate = query.NumberOfDays == 1
                    ? DateTime.Today.AddHours(DateTime.Now.Hour).AddHours(-23)
                    : DateTime.Today.AddDays(-query.NumberOfDays);
                cmd.AddParameter("minDate", minDate);

                using (var reader = await cmd.ExecuteReaderAsync())
                {
                    if (!await reader.ReadAsync())
                    {
                        throw new InvalidOperationException("Expected to be able to read.");
                    }

                    var data = new OverviewStatSummary {
                        Incidents = reader.GetInt32(0)
                    };
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Reports = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.Followers = reader.GetInt32(0);
                    await reader.NextResultAsync();

                    await reader.ReadAsync();

                    data.UserFeedback  = reader.GetInt32(0);
                    result.StatSummary = data;
                }
            }
        }