mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
28 lines
1.0 KiB
using System.Collections.Generic; |
|
using System.Data; |
|
using System.Linq; |
|
using System.Threading.Tasks; |
|
using Dapper; |
|
using ErsatzTV.Core.Interfaces.Repositories; |
|
using LanguageExt; |
|
|
|
namespace ErsatzTV.Infrastructure.Data.Repositories |
|
{ |
|
public class MediaItemRepository : IMediaItemRepository |
|
{ |
|
private readonly IDbConnection _dbConnection; |
|
|
|
public MediaItemRepository(IDbConnection dbConnection) => _dbConnection = dbConnection; |
|
|
|
public Task<List<string>> GetAllLanguageCodes() => |
|
_dbConnection.QueryAsync<string>( |
|
@"SELECT LanguageCode FROM |
|
(SELECT Language AS LanguageCode |
|
FROM MediaStream WHERE Language IS NOT NULL |
|
UNION ALL SELECT PreferredLanguageCode AS LanguageCode |
|
FROM Channel WHERE PreferredLanguageCode IS NOT NULL) |
|
GROUP BY LanguageCode |
|
ORDER BY COUNT(LanguageCode) DESC") |
|
.Map(result => result.ToList()); |
|
} |
|
}
|
|
|