ravendb /Raven.Database/Counters/Controllers/CounterStorageController.cs

Language C# Lines 44
MD5 Hash d91e9108d6f015f382ea9af2c3709b36
Repository https://github.com/nwendel/ravendb.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using Raven.Database.Server.Controllers;
using Raven.Json.Linq;

namespace Raven.Database.Counters.Controllers
{
    public class CounterStorageController : RavenDbApiController
    {
        [Route("counterStorage/conterStorages")]
        [HttpGet]
        public HttpResponseMessage GetCounterStoragesNames()
        {
            var names = GetCounterStorages();
            return GetMessageWithObject(names);
        }

		[Route("counterStorage/stats")]
		[HttpGet]
		public HttpResponseMessage GetCounterStoragesStats()
		{
			//TODO: implement getting the stats about the counter storages
			return GetEmptyMessage();
		}

        private string[] GetCounterStorages()
        {
            var start = GetStart();
            var nextPageStart = start; // will trigger rapid pagination
            var counterStorages = Database.Documents.GetDocumentsWithIdStartingWith("Raven/Counters/", null, null, start, GetPageSize(Database.Configuration.MaxPageSize), CancellationToken.None, ref nextPageStart);
            var counterStoragesNames = counterStorages
                                    .Select(x => x.Value<RavenJObject>("@metadata").Value<string>("@id").Replace("Raven/Counters/", string.Empty))
                                    .ToArray();
            return counterStoragesNames;
        }
    }
}
Back to Top