Mastodon connection helper tweaks (#13)

This commit is contained in:
Gervasio Marchand 2022-12-20 18:26:06 -08:00 committed by GitHub
parent 80bae5652b
commit 47a3e4acd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

3
.gitignore vendored
View File

@ -7,4 +7,5 @@ launchSettings.json
.idea/
.DS_Store
data/
output/
output/
*.DotSettings.user

View File

@ -6,16 +6,16 @@ public static class MastodonConnectionHelper
{
public static async Task<List<string>> GetFollowedTagsAsync()
{
var res = new List<string>();
if (Config.Instance == null)
if (Config.Instance == null) throw new Exception("Config object is not initialized");
if (Config.Instance.MastodonPostgresConnectionString.IsNullOrEmpty())
{
throw new Exception("Config object is not initialized");
throw new Exception("Missing mastodon postgres connection string");
}
await using var conn = new NpgsqlConnection(Config.Instance.MastodonPostgresConnectionString);
await conn.OpenAsync();
var res = new List<string>();
await using var cmd = new NpgsqlCommand("SELECT DISTINCT tags.name FROM tag_follows JOIN tags ON tag_id = tags.id ORDER BY tags.name ASC;", conn);
await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())