• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 9345538130

03 Jun 2024 06:46AM UTC coverage: 56.914%. Remained the same
9345538130

push

github

web-flow
Efficiency enhancements (#1829)

* More efficient checking for duplicates in lists

* GetValueOrDefault instead of manual fallback

* Update CommentStore.cs

Eliminate double-searching of CommentStore

* Eliminate more double-searches

* Update ExtractionConfiguration.cs

Clearer variable type, remove redundant casts

* Update ExecuteCommandAddPipelineComponent.cs

Make callbacks static for simplicity

* Update ColumnInfoANOPlan.cs

Join declaration and initialisation

* More GetValueOrDefault

* Simplify searching logic - Where(x).First() -> First(x) to avoid repeating copying

* Update CatalogueChildProvider.cs

Simplify list generation logic

* Update DleRunner.cs

Remove redundant counting of list size

* Null-coalesce, usings

* Lambdas

* Update YesNoYesToAllDialog.cs

Avoid thread-thrashing if yes or no to all has been clicked

* Method groups, static lambdas

* Avoid multiple lookups when iterating arrays

* Simplify null checks

* String interpolation, another loop deref

* Update CohortIdentificationTaskExecution.cs

Fix duplicate Dispose calls

* Update RemoteAttacher.cs

Make fake conditional value a constant

* Fix multiple enumerations

A

* Type check and cast combination

* Update RemoteAttacherTests.cs

String interpolation, object initialisers

* Turn some private fields to local variables where applicable

* No-op string interpolations

* Remove some redundant syntax

10817 of 20482 branches covered (52.81%)

Branch coverage included in aggregate %.

152 of 231 new or added lines in 53 files covered. (65.8%)

3 existing lines in 2 files now uncovered.

30827 of 52688 relevant lines covered (58.51%)

7412.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/Rdmp.Core/DataLoad/Engine/Migration/QueryBuilding/MigrationQueryHelper.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
namespace Rdmp.Core.DataLoad.Engine.Migration.QueryBuilding;
8

9
/// <summary>
10
/// Generates the MERGE and UPDATE SQL queries responsible for migrating records from STAGING to LIVE as part of a data load.
11
/// </summary>
12
public abstract class MigrationQueryHelper
13
{
14
    protected readonly MigrationColumnSet ColumnsToMigrate;
15
    protected readonly MigrationColumnSetQueryHelper McsQueryHelper;
16

17
    protected MigrationQueryHelper(MigrationColumnSet columnsToMigrate)
58✔
18
    {
19
        ColumnsToMigrate = columnsToMigrate;
58✔
20
        McsQueryHelper = new MigrationColumnSetQueryHelper(ColumnsToMigrate);
58✔
21
    }
58✔
22

23
    public virtual string CreateUpdateQuery()
24
    {
NEW
25
        return $"WITH ToUpdate AS (SELECT stag.* FROM {ColumnsToMigrate.SourceTable.GetFullyQualifiedName()} AS stag LEFT OUTER JOIN {ColumnsToMigrate.DestinationTable.GetFullyQualifiedName()} AS prod {McsQueryHelper.BuildJoinClause("stag", "prod")} WHERE {McsQueryHelper.BuildPrimaryKeyNotNullTest("stag.")} AND {McsQueryHelper.BuildPrimaryKeyNotNullTest("prod.")} AND EXISTS (SELECT {McsQueryHelper.BuildSelectListForAllColumnsExceptStandard("stag.")} EXCEPT SELECT {McsQueryHelper.BuildSelectListForAllColumnsExceptStandard("prod.")})) {CreateUpdateClause()}";
×
26
    }
27

28
    public string CreateUpdateClause()
29
    {
30
        const string joinTableName = "ToUpdate";
31

NEW
32
        return
×
NEW
33
            $"UPDATE prod SET {BuildUpdateClauseForRow(joinTableName, "prod")} FROM {ColumnsToMigrate.DestinationTable.GetFullyQualifiedName()} AS prod INNER JOIN {joinTableName} {McsQueryHelper.BuildJoinClause(joinTableName, "prod")} SELECT @@ROWCOUNT";
×
34
    }
35

36

37
    public abstract string BuildUpdateClauseForRow(string sourceAlias, string destAlias);
38
    public abstract string BuildInsertClause();
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc