Skip to content

Commit

Permalink
tidy up for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Oct 28, 2024
1 parent cb41028 commit 9885dc9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 58 deletions.
72 changes: 17 additions & 55 deletions Rdmp.Core/Curation/Data/Overview/OverviewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,23 @@ private void GetDataLoads()
_dataLoads = new();
var repo = new MemoryCatalogueRepository();
var qb = new QueryBuilder(null, null);
var columnInfo = _catalogue.CatalogueItems.Where(c => c.Name == SpecialFieldNames.DataLoadRunID).Select(c => c.ColumnInfo).First();
qb.AddColumn(new ColumnInfoToIColumn(repo, columnInfo));
qb.AddCustomLine($"{columnInfo.Name} IS NOT NULL", FAnsi.Discovery.QuerySyntax.QueryComponent.WHERE);
var sql = qb.SQL;
var server = columnInfo.Discover(DataAccessContext.InternalDataProcessing).Table.Database.Server;
using var con = server.GetConnection();
con.Open();

using var cmd = server.GetCommand(sql, con);
cmd.CommandTimeout = 30000;
using var da = server.GetDataAdapter(cmd);
_dataLoads.BeginLoadData();
da.Fill(_dataLoads);
_dataLoads.EndLoadData();
var columnInfo = _catalogue.CatalogueItems.Where(c => c.Name == SpecialFieldNames.DataLoadRunID).Select(c => c.ColumnInfo).FirstOrDefault();
if (columnInfo != null)
{
qb.AddColumn(new ColumnInfoToIColumn(repo, columnInfo));
qb.AddCustomLine($"{columnInfo.Name} IS NOT NULL", FAnsi.Discovery.QuerySyntax.QueryComponent.WHERE);
var sql = qb.SQL;
var server = columnInfo.Discover(DataAccessContext.InternalDataProcessing).Table.Database.Server;
using var con = server.GetConnection();
con.Open();

using var cmd = server.GetCommand(sql, con);
cmd.CommandTimeout = 30000;
using var da = server.GetDataAdapter(cmd);
_dataLoads.BeginLoadData();
da.Fill(_dataLoads);
_dataLoads.EndLoadData();
}

}

Expand All @@ -159,47 +162,6 @@ public DataTable GetDataLoadDetails()
return dt;
}

//public DataTable GetDataLoadsuccessRate()
//{
// if (_dataLoads == null) GetDataLoads();
// DataTable dt = new();
// var loggingServers = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere<ExternalDatabaseServer>("CreatedByAssembly", "Rdmp.Core/Databases.LoggingDatabase");
// var columnInfo = _catalogue.CatalogueItems.Where(c => c.Name == SpecialFieldNames.DataLoadRunID).Select(c => c.ColumnInfo).First();
// var server = columnInfo.Discover(DataAccessContext.InternalDataProcessing).Table.Database.Server;
// foreach (var loggingServer in loggingServers)
// {
// var logCollection = new ViewLogsCollection(loggingServer, new LogViewerFilter(LoggingTables.FatalError));
// var dataLoadRunSql = $"{logCollection.GetSql()}";
// var logServer = loggingServer.Discover(DataAccessContext.InternalDataProcessing).Server;
// using var loggingCon = logServer.GetConnection();
// loggingCon.Open();
// using var loggingCmd = logServer.GetCommand(dataLoadRunSql, loggingCon);
// loggingCmd.CommandTimeout = 30000;
// using var loggingDa = server.GetDataAdapter(loggingCmd);
// dt.BeginLoadData();
// loggingDa.Fill(dt);
// dt.EndLoadData();
// loggingCon.Dispose();
// if (dt.Rows.Count > 0)
// {
// //if we've found it, then stop
// break;
// }
// }
// var failureIds = dt.AsEnumerable().Select(row => row[5]).Distinct().ToList();
// var ids = _dataLoads.AsEnumerable().Select(row => row[0]).Distinct().ToList();


// int failed = ids.Intersect(failureIds).Count();
// int success = _dataLoads.Rows.Count - failed;
// DataTable results = new();
// results.Columns.Add("success");
// results.Columns.Add("failed");
// results.Rows.Add(success, failed);

// return results;
//}

public DataTable GetMostRecentDataLoad()
{
if (_dataLoads == null) GetDataLoads();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
using Rdmp.UI.ExtractionUIs;
using Rdmp.UI.ItemActivation;
using Rdmp.UI.Overview;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Rdmp.Core.Curation.Data.Overview;
using Rdmp.UI.ExtractionUIs;
using Rdmp.UI.ItemActivation;
using Rdmp.UI.Overview;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Rdmp.UI/Overview/ViewCatalogueOverviewUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
using ScintillaNET;
using SixLabors.ImageSharp.PixelFormats;

namespace Rdmp.UI.ExtractionUIs;
namespace Rdmp.UI.Overview;

/// <summary>
/// Allows you to view the Extraction SQL that is built by the QueryBuilder when extracting or running data quality engine against a dataset (Catalogue). Includes options for
Expand All @@ -40,7 +40,7 @@ namespace Rdmp.UI.ExtractionUIs;
/// <para>If for some reason you see an error instead of your extraction SQL then read the description and take the steps it suggests (e.g. if it is complaining about not knowing
/// how to JOIN two tables then configure an appropriate JoinInfo - See JoinConfiguration). </para>
/// </summary>
public partial class ViewCatalogueOverviewUI : ViewExtractionSql_Design
public partial class ViewCatalogueOverviewUI : ViewCatalogueOverview_Design
{
private Catalogue _catalogue;
private OverviewModel _overview;
Expand Down

0 comments on commit 9885dc9

Please sign in to comment.