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

samsmithnz / RepoGovernance / 16726832225

04 Aug 2025 03:04PM UTC coverage: 71.373% (-1.4%) from 72.727%
16726832225

push

github

web-flow
Updated to handle new items easier. (#981)

* Updated to handle new items easier.

* FIx to update test

* Update src/RepoGovernance.Core/TableStorage/AzureTableStorageDA.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

352 of 530 branches covered (66.42%)

Branch coverage included in aggregate %.

4 of 37 new or added lines in 3 files covered. (10.81%)

3 existing lines in 1 file now uncovered.

937 of 1276 relevant lines covered (73.43%)

40.59 hits per line

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

68.75
/src/RepoGovernance.Core/TableStorage/AzureTableStorageDA.cs
1
using RepoAutomation.Core.APIAccess;
2
using RepoGovernance.Core.Models;
3
using System.Text.Json;
4

5
namespace RepoGovernance.Core.TableStorage
6
{
7
    //Note that these calls to Azure Storage table can't be async due to performance issues with Azure Storage when you retrieve items
8
    public static class AzureTableStorageDA
9
    {
10
        public static async Task<List<UserOwnerRepo>> GetUserOwnerRepoItemsFromTable(string connectionString, string tableName,
11
            string partitionKey)
12
        {
1✔
13
            TableStorageCommonDA tableDA = new(connectionString, tableName);
1✔
14
            List<AzureStorageTableModel> items = await tableDA.GetItems(partitionKey);
1✔
15
            List<UserOwnerRepo> results = new();
1✔
16
            foreach (AzureStorageTableModel item in items)
49✔
17
            {
23✔
18
                string? data = item.RowKey.ToString();
23✔
19
                if (data != null)
23✔
20
                {
23✔
21
                    results.Add(new UserOwnerRepo(data.Split('_')[0], data.Split('_')[1], data.Split('_')[2]));
23✔
22
                }
23✔
23
            }
23✔
24
            return results;
1✔
25
        }
1✔
26

27
        public static async Task<List<SummaryItem>> GetSummaryItemsFromTable(string connectionString, string tableName,
28
            string partitionKey, string? gitHubId, string? gitHubSecret)
29
        {
4✔
30
            TableStorageCommonDA tableDA = new(connectionString, tableName);
4✔
31
            List<AzureStorageTableModel> items = await tableDA.GetItems(partitionKey);
4✔
32
            List<SummaryItem> results = new();
4✔
33
            foreach (AzureStorageTableModel item in items)
220✔
34
            {
104✔
35
                string? data = item.Data?.ToString();
104!
36
                if (string.IsNullOrEmpty(data) == false)
104!
37
                {
104✔
38
                    SummaryItem? summaryItem = JsonSerializer.Deserialize<SummaryItem>(data);
104✔
39
                    if (summaryItem != null)
104✔
40
                    {
104✔
41
                        results.Add(summaryItem);
104✔
42
                    }
104✔
43
                }
104✔
44
                else
NEW
45
                {
×
NEW
46
                    if (item.RowKey != null)
×
NEW
47
                    {
×
NEW
48
                        string[] keys = item.RowKey.Split('_');
×
NEW
49
                        if (keys.Length == 2)
×
NEW
50
                        {
×
NEW
51
                            SummaryItem newSummaryItem = new(partitionKey, keys[0], keys[1]);
×
NEW
52
                            RepoAutomation.Core.Models.Repo? repoSettings = await GitHubApiAccess.GetRepo(gitHubId, gitHubSecret, keys[0], keys[1]);
×
NEW
53
                            if (repoSettings != null)
×
NEW
54
                            {
×
NEW
55
                                newSummaryItem.RepoSettings = repoSettings;
×
NEW
56
                            }
×
NEW
57
                            await UpdateSummaryItemsIntoTable(connectionString, partitionKey, keys[0], keys[1], newSummaryItem);
×
NEW
58
                            results.Add(newSummaryItem);
×
NEW
59
                        }
×
NEW
60
                    }
×
NEW
61
                }
×
62
            }
104✔
63
            return results;
4✔
64
        }
4✔
65

66
        //Update the storage with the data
67
        public static async Task<int> UpdateSummaryItemsIntoTable(string connectionString,
68
                string user, string owner, string repo, SummaryItem summaryItem)
69
        {
6✔
70
            int itemsAdded = 0;
6✔
71
            TableStorageCommonDA tableBuildsDA = new(connectionString, "Summary");
6✔
72
            string json = JsonSerializer.Serialize(summaryItem);
6✔
73
            string partitionKey = user;
6✔
74
            string rowKey = owner + "_" + repo;
6✔
75

76
            AzureStorageTableModel row = new(partitionKey, rowKey, json);
6✔
77
            await tableBuildsDA.SaveItem(row);
6✔
78
            itemsAdded++;
6✔
79

80
            return itemsAdded;
6✔
81
        }
6✔
82

83
    }
84
}
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