v-lipi@microsoft.com 2017-01-06 16:54:12 +08:00
Родитель 2a5b4d3d49 0b234bc8ac
Коммит eaa1df678f
6 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -40,7 +40,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
public async Task<IEnumerable<Filter>> GetRecentFiltersAsync(int max)
{
var filters = await _filterRepository.GetRecentFiltersAsync(max);
var filters = await _filterRepository.GetRecentFiltersAsync(max, true);
return filters.Select(filter => new Filter(filter));
}

Просмотреть файл

@ -120,12 +120,12 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
return (result.Status == TableStorageResponseStatus.Successful);
}
public async Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max = 20)
public async Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max = 20, bool excludeTemporary = true)
{
TableQuery<DeviceListFilterTableEntity> query = new TableQuery<DeviceListFilterTableEntity>();
var entities = await _filterTableStorageClient.ExecuteQueryAsync(query);
// replace the timestamp of default filter with current time so that it is always sorted at top of filter list.
var ordered = entities.Select(e =>
var ordered = entities.Where(e => !excludeTemporary || !e.IsTemporary).Select(e =>
{
if (e.Id.Equals(DefaultDeviceListFilter.Id))
{

Просмотреть файл

@ -46,7 +46,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
/// Return recenty queries executed recently, sorted by timestamp.
/// </summary>
/// <returns>a set of queries</returns>
Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max=20);
Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max, bool excludeTemporary);
/// <summary>
/// Delete the saved filter by name.

Просмотреть файл

@ -65,7 +65,6 @@
<img src="/Content/img/column_delete.svg" data-bind="click: $parent.unCheckClause" />
</div>
</div>
<a href="#" class="device_list_clause_clear" data-bind="visible: checkedClauses().length > 0, click: unCheckAllClauses">@Strings.ClearAll</a>
<!-- /ko -->
<!--ko if: isAdvanced() && advancedClause() -->
<div class="device_list_clause" data-bind="attr: { title: advancedClause }">

Просмотреть файл

@ -241,6 +241,13 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
var expectedNams = tableEntities.OrderByDescending(e => e.Timestamp).Take(max).Select(e => e.Name).ToArray();
Assert.Equal(max, ret.Count());
Assert.Equal(expectedNams, ret.Select(e => e.Name).ToArray());
filters.Take(max).All(f => f.IsTemporary = true);
tableEntities = filters.Select(f => new DeviceListFilterTableEntity(f));
ret = await deviceListFilterRepository.GetRecentFiltersAsync(max, false);
Assert.Equal(max, ret.Count());
ret = await deviceListFilterRepository.GetRecentFiltersAsync(max, true);
Assert.Equal(40 - max, ret.Count());
}
[Fact]

Просмотреть файл

@ -55,7 +55,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
{
filter.Clauses = null;
}
_deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny<int>())).ReturnsAsync(filters.Take(3));
_deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny<int>(), It.IsAny<bool>())).ReturnsAsync(filters.Take(3));
var ret = await _filterLogic.GetRecentFiltersAsync(3);
Assert.Equal(3, ret.Count());
}