diff --git a/src/OnePeek.Api/OnePeekApi.cs b/src/OnePeek.Api/OnePeekApi.cs
index 9ec98f8..e863358 100644
--- a/src/OnePeek.Api/OnePeekApi.cs
+++ b/src/OnePeek.Api/OnePeekApi.cs
@@ -152,7 +152,7 @@ namespace OnePeek.Api
/// The store where the app is published.
/// Culture of the query (returns location specific metadata + ratings).
///
- public async Task> GetSpotlightIds(StoreSpotlightType spotlightType, StoreType store, StoreCultureType storeCulture)
+ public async Task GetSpotlightIds(StoreSpotlightType spotlightType, StoreType store, StoreCultureType storeCulture)
{
if (storeCulture == StoreCultureType.Unknown || storeCulture == StoreCultureType.All)
{
@@ -161,10 +161,22 @@ namespace OnePeek.Api
Uri uri = EndpointUris.GetWindowsPhoneSpotlightUri(storeCulture.ToString(), spotlightType.GetEnumDisplayName());
- string xml = await ApiHttpClient.Instance.Get(uri);
+ try
+ {
+ string xml = await ApiHttpClient.Instance.Get(uri);
- IEnumerable ids = XDocument.Parse(xml).Elements().First().Descendants().Where(x => x.Name.LocalName == "application").Select(x => x.Descendants().Get("id").Split(':').Last());
- return ids;
+ IEnumerable ids = XDocument.Parse(xml).Elements().First().Descendants().Where(x => x.Name.LocalName == "application").Select(x => x.Descendants().Get("id").Split(':').Last());
+
+ return new StoreSpotlightIdResults()
+ {
+ StoreCultureType = storeCulture,
+ Ids = ids
+ };
+ }
+ catch
+ {
+ return null;
+ }
}
@@ -403,6 +415,29 @@ namespace OnePeek.Api
return await Task.WhenAll(tasks).ConfigureAwait(false);
}
+
+
+
+ ///
+ /// Get spotlight entries for the current day in the specified culture.
+ /// This only returns IDs for fast access.
+ /// Warning: This method makes a request per culture (100+) which can take a while.
+ ///
+ /// Can either be apps or games. Both return approx. 20 new results per day.
+ /// The store where the app is published.
+ /// The canellation token.
+ /// The progress event gets triggered as soon as new data arrives.
+ ///
+ public async Task> GetSpotlightIdsForAllCultures(StoreSpotlightType spotlightType, StoreType store, CancellationToken ct, IProgress progress = null)
+ {
+ IEnumerable cultures = Enum.GetValues(typeof(StoreCultureType))
+ .Cast()
+ .Where(x => x != StoreCultureType.All && x != StoreCultureType.Unknown);
+
+ IEnumerable> tasks = cultures.Select(culture => GetSpotlightIds(spotlightType, store, culture));
+
+ return (await Task.WhenAll(tasks).ConfigureAwait(false)).Where(x => x != null);
+ }
}
diff --git a/src/OnePeek.Entities/StoreSpotlightResults.cs b/src/OnePeek.Entities/StoreSpotlightResults.cs
index 4fa2b6f..0fa06bb 100644
--- a/src/OnePeek.Entities/StoreSpotlightResults.cs
+++ b/src/OnePeek.Entities/StoreSpotlightResults.cs
@@ -33,4 +33,19 @@ namespace OnePeek.Entities
///
public IEnumerable Results { get; set; }
}
+
+
+ public partial class StoreSpotlightIdResults
+ {
+ ///
+ /// The culture is relevant for the review results,
+ /// as they are unique per country
+ ///
+ public StoreCultureType StoreCultureType { get; set; }
+
+ ///
+ /// List of result ids.
+ ///
+ public IEnumerable Ids { get; set; }
+ }
}
diff --git a/src/OnePeek.WebConsole/Modules/HomeModule.cs b/src/OnePeek.WebConsole/Modules/HomeModule.cs
index e219c31..1d3b35a 100644
--- a/src/OnePeek.WebConsole/Modules/HomeModule.cs
+++ b/src/OnePeek.WebConsole/Modules/HomeModule.cs
@@ -4,6 +4,8 @@ using OnePeek.Entities;
using System.Collections.Generic;
using System.Linq;
using System.IO;
+using System.Threading;
+using System;
namespace OnePeek.WebConsole.Modules
{
@@ -19,11 +21,8 @@ namespace OnePeek.WebConsole.Modules
StoreSpotlightResults apps = await api.GetSpotlight(StoreSpotlightType.Apps, StoreType.WindowsPhone8, StoreCultureType.EN_US);
StoreSpotlightResults games = await api.GetSpotlight(StoreSpotlightType.Games, StoreType.WindowsPhone8, StoreCultureType.EN_US);
- IEnumerable appIds = await api.GetSpotlightIds(StoreSpotlightType.Apps, StoreType.WindowsPhone8, StoreCultureType.EN_US);
-
return View["Index", new
{
- SpotlightIds = appIds,
Spotlight = apps,
SpotlightGames = games
}];
@@ -51,6 +50,20 @@ namespace OnePeek.WebConsole.Modules
};
+ Get["/spotlight", true] = async (ctx, token) =>
+ {
+ IEnumerable results = await api.GetSpotlightIdsForAllCultures(StoreSpotlightType.Apps, StoreType.WindowsPhone8, default(CancellationToken));
+
+ Dictionary count = results
+ .SelectMany(x => x.Ids)
+ .GroupBy(x => x)
+ .OrderByDescending(x => x.Count())
+ .ToDictionary(x => x.Key, x => x.Count());
+
+ return View["Spotlight", count];
+ };
+
+
Get["/ratings", true] = async (ctx, token) =>
{
var order = Request.Query["order"];
diff --git a/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj b/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj
index ccbe5bc..8a697ce 100644
--- a/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj
+++ b/src/OnePeek.WebConsole/OnePeek.WebConsole.csproj
@@ -81,6 +81,7 @@
+
Web.config
diff --git a/src/OnePeek.WebConsole/Views/Index.cshtml b/src/OnePeek.WebConsole/Views/Index.cshtml
index 97c30a2..13b164f 100644
--- a/src/OnePeek.WebConsole/Views/Index.cshtml
+++ b/src/OnePeek.WebConsole/Views/Index.cshtml
@@ -36,6 +36,14 @@
+
+
SPOTLIGHT SUMMARY
+
load
+
+
+
+
+
APPS SPOTLIGHT
@@ -75,6 +83,7 @@
+
diff --git a/src/OnePeek.WebConsole/Views/Spotlight.cshtml b/src/OnePeek.WebConsole/Views/Spotlight.cshtml
new file mode 100644
index 0000000..1d705e5
--- /dev/null
+++ b/src/OnePeek.WebConsole/Views/Spotlight.cshtml
@@ -0,0 +1,21 @@
+@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
+@{
+ Layout = "_Layout.cshtml";
+}
+
+
+
+@foreach (var kv in Model)
+{
+
+}
+
+
\ No newline at end of file