From 9c5cceb4ecc277ffb5a3a988f655ad674bf41c58 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 14 Aug 2014 09:24:30 -0400 Subject: update translations --- .../Activity/ActivityRepository.cs | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Activity/ActivityRepository.cs') diff --git a/MediaBrowser.Server.Implementations/Activity/ActivityRepository.cs b/MediaBrowser.Server.Implementations/Activity/ActivityRepository.cs index 787cbcc5b..f491a5c44 100644 --- a/MediaBrowser.Server.Implementations/Activity/ActivityRepository.cs +++ b/MediaBrowser.Server.Implementations/Activity/ActivityRepository.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Server.Implementations.Activity } } - public QueryResult GetActivityLogEntries(int? startIndex, int? limit) + public QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit) { using (var cmd = _connection.CreateCommand()) { @@ -147,17 +147,33 @@ namespace MediaBrowser.Server.Implementations.Activity var whereClauses = new List(); - if (startIndex.HasValue && startIndex.Value > 0) + if (minDate.HasValue) { - whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM ActivityLogEntries ORDER BY DateCreated DESC LIMIT {0})", - startIndex.Value.ToString(_usCulture))); + whereClauses.Add("DateCreated>=@DateCreated"); + cmd.Parameters.Add(cmd, "@DateCreated", DbType.Date).Value = minDate.Value; } - if (whereClauses.Count > 0) + var whereTextWithoutPaging = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); + + if (startIndex.HasValue && startIndex.Value > 0) { - cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray()); + var pagingWhereText = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); + + whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM ActivityLogEntries {0} ORDER BY DateCreated DESC LIMIT {1})", + pagingWhereText, + startIndex.Value.ToString(_usCulture))); } + var whereText = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray()); + + cmd.CommandText += whereText; + cmd.CommandText += " ORDER BY DateCreated DESC"; if (limit.HasValue) @@ -165,7 +181,7 @@ namespace MediaBrowser.Server.Implementations.Activity cmd.CommandText += " LIMIT " + limit.Value.ToString(_usCulture); } - cmd.CommandText += "; select count (Id) from ActivityLogEntries"; + cmd.CommandText += "; select count (Id) from ActivityLogEntries" + whereTextWithoutPaging; var list = new List(); var count = 0; -- cgit v1.2.3