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

HicServices / RDMP / 26566925905

28 May 2026 09:37AM UTC coverage: 57.023% (-0.08%) from 57.101%
26566925905

push

github

JFriel
Merge branch 'bugfix/cohort-commit-issue' of https://github.com/HicServices/RDMP into bugfix/cohort-commit-issue

11562 of 21813 branches covered (53.01%)

Branch coverage included in aggregate %.

32688 of 55787 relevant lines covered (58.59%)

18057.84 hits per line

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

10.71
/Rdmp.Core/DataViewing/ViewAggregateExtractUICollection.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
using System;
8
using System.Collections.Generic;
9
using System.Linq;
10
using FAnsi.Discovery.QuerySyntax;
11
using Rdmp.Core.Curation.Data;
12
using Rdmp.Core.Curation.Data.Aggregation;
13
using Rdmp.Core.Curation.Data.Dashboarding;
14
using Rdmp.Core.QueryBuilding;
15
using Rdmp.Core.ReusableLibraryCode.DataAccess;
16

17
namespace Rdmp.Core.DataViewing;
18

19
/// <summary>
20
/// Builds a query based on a <see cref="AggregateConfiguration"/> (either a sample of data in a graph or matching a cohort
21
/// (<see cref="AggregateConfiguration.IsCohortIdentificationAggregate"/>)
22
/// </summary>
23
public class ViewAggregateExtractUICollection : PersistableObjectCollection, IViewSQLAndResultsCollection
24
{
25
    public bool UseQueryCache { get; set; }
×
26
    public bool DisableRun => false;
×
27

28

29
    /// <summary>
30
    /// How big should the sample be
31
    /// </summary>
32
    public int? TopX { get; set; } = 100;
20✔
33

34
    public ViewAggregateExtractUICollection()
10✔
35
    {
36
    }
10✔
37

38
    public ViewAggregateExtractUICollection(AggregateConfiguration config) : this()
10✔
39
    {
40
        DatabaseObjects.Add(config);
10✔
41
    }
10✔
42

43
    public IEnumerable<DatabaseEntity> GetToolStripObjects()
44
    {
45
        if (!UseQueryCache) yield break;
×
46
        var cache = GetCacheServer();
×
47
        if (cache != null)
×
48
            yield return cache;
×
49
    }
×
50

51
    private ExternalDatabaseServer GetCacheServer()
52
    {
53
        var cic = AggregateConfiguration.GetCohortIdentificationConfigurationIfAny();
×
54
        return cic is { QueryCachingServer_ID: not null } ? cic.QueryCachingServer : null;
×
55
    }
56

57
    public IDataAccessPoint GetDataAccessPoint()
58
    {
59
        var dim = AggregateConfiguration.AggregateDimensions.FirstOrDefault();
×
60

61
        //the aggregate has no dimensions
62
        if (dim != null) return dim.ColumnInfo.TableInfo;
×
63
        var table = AggregateConfiguration.ForcedJoins.FirstOrDefault() ?? throw new Exception(
×
64
            $"AggregateConfiguration '{AggregateConfiguration}' has no AggregateDimensions and no TableInfo forced joins, we do not know where/what table to run the query on");
×
65
        return table;
×
66
    }
67

68
    public string GetSql()
69
    {
70
        var ac = AggregateConfiguration;
×
71

72
        if (!ac.IsCohortIdentificationAggregate) return ac.GetQueryBuilder().SQL;
×
73

74
        var cic = ac.GetCohortIdentificationConfigurationIfAny();
×
75
        var globals = cic.GetAllParameters();
×
76

77
        var builder = new CohortQueryBuilder(ac, globals, null);
×
78

79
        if (UseQueryCache)
×
80
            builder.CacheServer = GetCacheServer();
×
81

82
        return TopX.HasValue ? builder.GetDatasetSampleSQL(TopX.Value) : builder.SQL;
×
83
    }
84

85
    public string GetTabName() => $"View Top 100 {AggregateConfiguration}";
×
86

87
    public void AdjustAutocomplete(IAutoCompleteProvider autoComplete)
88
    {
89
        if (AggregateConfiguration != null)
×
90
            autoComplete.Add(AggregateConfiguration);
×
91
    }
×
92

93
    private AggregateConfiguration AggregateConfiguration =>
94
        DatabaseObjects.OfType<AggregateConfiguration>().SingleOrDefault();
×
95

96
    public IQuerySyntaxHelper GetQuerySyntaxHelper() => AggregateConfiguration?.GetQuerySyntaxHelper();
×
97
}
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

© 2026 Coveralls, Inc