Skip to content

Commit

Permalink
Merge d8f1f40 into ba3f7e8
Browse files Browse the repository at this point in the history
  • Loading branch information
samsmithnz committed Jan 9, 2023
2 parents ba3f7e8 + d8f1f40 commit d63e773
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public static class BaseApi
T? obj = default;
if (client != null && url != null)
{
//Debug.WriteLine("Running url: " + client.BaseAddress.ToString() + url);
//Console.WriteLine("Running url: " + client.BaseAddress.ToString() + url);
using (HttpResponseMessage response = await client.GetAsync(url))
{
if (ignoreErrors == true || response.IsSuccessStatusCode == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public static class SonarCloudApi
string? obj = null;
if (client != null && url != null)
{
//Debug.WriteLine("Running url: " + client.BaseAddress.ToString() + url);
//Console.WriteLine("Running url: " + client.BaseAddress.ToString() + url);
using (HttpResponseMessage response = await client.GetAsync(url))
{
if (ignoreErrors == true || response.IsSuccessStatusCode == true)
Expand Down
15 changes: 0 additions & 15 deletions src/RepoGovernance.Core/TableStorage/AzureTableStorageDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,9 @@ public static class AzureTableStorageDA
AzureStorageTableModel row = new(partitionKey, rowKey, json);
await tableBuildsDA.SaveItem(row);
itemsAdded++;
//if (await tableBuildsDA.AddItem(row) == true)
//{
// itemsAdded++;
//}
//else
//{
// await tableBuildsDA.SaveItem(row);
// itemsAdded++;
//}

return itemsAdded;
}

////TODO: Move this into Azure Storage - currently this is a single static list of repos
//public static List<UserOwnerRepo> GetRepos(string user)
//{
// return DatabaseAccess.GetRepos(user);
//}

}
}
63 changes: 2 additions & 61 deletions src/RepoGovernance.Core/TableStorage/TableStorageCommonDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,14 @@ private CloudTable CreateConnection()
CloudTable table = tableClient.GetTableReference(TableName);

// Create the table if it doesn't exist
//table.CreateIfNotExists(); // DON"T use CreateIfNotExists, it throws an internal 409 in App insights: https://stackoverflow.com/questions/48893519/azure-table-storage-exception-409-conflict-unexpected
// DON"T use table.CreateIfNotExists, it throws an internal 409 in App insights: https://stackoverflow.com/questions/48893519/azure-table-storage-exception-409-conflict-unexpected
if (!table.Exists())
{
table.Create();
}

return table;
}

//public async Task<bool> AddItem(AzureStorageTableModel data, bool forceUpdate = false)
//{
// //Check if the item exists in storage
// AzureStorageTableModel item = await GetItem(data.PartitionKey, data.RowKey);
// if (item == null || forceUpdate == true)
// {
// await SaveItem(data);
// return true; //data saved to table!
// }
// else
// {
// return false; //no updates needed
// }
//}
}

public async Task<AzureStorageTableModel> GetItem(string partitionKey, string rowKey)
{
Expand Down Expand Up @@ -94,57 +79,13 @@ public async Task<bool> SaveItem(AzureStorageTableModel data)
return true;
}

////public async Task<bool> DeleteItem(string tableName, string name)
////{
//// CloudTable table = CreateConnection(tableName);

//// // Create a retrieve operation that expects a customer entity.
//// TableOperation retrieveOperation = TableOperation.Retrieve<T>("Item", name);

//// // Execute the operation.
//// TableResult retrievedResult = await table.ExecuteAsync(retrieveOperation);

//// // Assign the result to a CustomerEntity object.
//// T deleteEntity = (T)retrievedResult.Result;

//// if (deleteEntity != null)
//// {
//// // Create the TableOperation that inserts the customer entity.
//// TableOperation deleteOperation = TableOperation.Delete(deleteEntity);

//// // Execute the delete operation.
//// await table.ExecuteAsync(deleteOperation);
//// }
//// return true;
////}

public static string EncodePartitionKey(string text)
{
//The forward slash(/) character
//The backslash(\) character
//The number sign(#) character
//The question mark (?) character
text = text.Replace("/", "_");
//text = text.Replace("\\", "_");
//text = text.Replace("#", "_");
//text = text.Replace("?", "_");

////Control characters from U+0000 to U+001F, including:
////The horizontal tab(\t) character
//text = text.Replace("\t", "_");
////The linefeed(\n) character
//text = text.Replace("\n", "_");
////The carriage return (\r) character
//text = text.Replace("\r", "_");
////Control characters from U + 007F to U+009F

return text;
}

//public string DecodePartitionKey(string text)
//{
// return text.Replace("_", "/");
//}

}
}
7 changes: 1 addition & 6 deletions src/RepoGovernance.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public async Task<IActionResult> Index()
}
}
}
//foreach (RepoLanguage repoLanguage in summaryItem.RepoLanguages)
//{
// Debug.WriteLine(summaryItem.Repo + ":" + repoLanguage.Name + ":" + repoLanguage.Total);
//}
}
//Update the percent
foreach (KeyValuePair<string, int> sortedLanguage in repoLanguagesDictonary.OrderByDescending(x => x.Value))
Expand All @@ -73,11 +69,10 @@ public async Task<IActionResult> Index()
return View(summaryItemsIndex);
}

//[HttpPost]
public async Task<IActionResult> UpdateRow(string user, string owner, string repo)
{
await _ServiceApiClient.UpdateSummaryItem(user, owner, repo);
return RedirectToAction("Index");
return Redirect(Url.RouteUrl(new { controller = "Home", action = "Index" }) + "#" + repo);
}

public async Task<IActionResult> UpdateAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public async Task<List<T>> ReadMessageList<T>(Uri url)
StreamReader reader = new(stream);
string text = reader.ReadToEnd();
return JsonConvert.DeserializeObject<List<T>>(text);
//return await JsonSerializer.DeserializeAsync<List<T>>(stream);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/RepoGovernance.Web/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<div class="row rowStyle">
<div class="col-md-5">
<div>
<a id="@item.Repo"></a>
<a href="https://github.com/samsmithnz/@item.Repo" target="_blank" class="projectHeader">@item.Repo</a> <span class="publicPrivateLabel">&nbsp;&nbsp;@visibility&nbsp;&nbsp;</span><br>
<span class="descriptionText">@item.RepoSettings.description</span><br>
</div>
Expand Down

0 comments on commit d63e773

Please sign in to comment.