| | 1 | | using Dapper; |
| | 2 | | using Npgsql; |
| | 3 | |
|
| | 4 | | namespace Syki.Back.Features.Adm.GetAdmInsights; |
| | 5 | |
|
| 1 | 6 | | public class GetAdmInsightsService(DatabaseSettings settings) : IAdmService |
| | 7 | | { |
| | 8 | | public async Task<AdmInsightsOut> Get() |
| | 9 | | { |
| 1 | 10 | | using var connection = new NpgsqlConnection(settings.ConnectionString); |
| | 11 | |
|
| | 12 | | const string sql = @" |
| | 13 | | SELECT |
| | 14 | | COUNT(1)-1 AS institutions, |
| | 15 | | (SELECT COUNT(1)-1 FROM syki.users) AS users, |
| | 16 | | (SELECT COUNT(1) FROM syki.campi) AS campi, |
| | 17 | | (SELECT COUNT(1) FROM syki.courses) AS courses, |
| | 18 | | (SELECT COUNT(1) FROM syki.disciplines) AS disciplines, |
| | 19 | | (SELECT COUNT(1) FROM syki.course_curriculums) AS course_curriculums, |
| | 20 | | (SELECT COUNT(1) FROM syki.course_offerings) AS course_offerings, |
| | 21 | | (SELECT COUNT(1) FROM syki.teachers) AS teachers, |
| | 22 | | (SELECT COUNT(1) FROM syki.students) AS students |
| | 23 | | FROM |
| | 24 | | syki.institutions |
| | 25 | | "; |
| | 26 | |
|
| 1 | 27 | | return await connection.QueryFirstAsync<AdmInsightsOut>(sql); |
| 1 | 28 | | } |
| | 29 | | } |