added job parallel lock, file structure, diagnostics
This commit is contained in:
parent
bf55f7222e
commit
35c24ad0ef
@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Selector.CLI.Jobs
|
||||
{
|
||||
[DisallowConcurrentExecution]
|
||||
public class ScrobbleWatcherJob : IJob
|
||||
{
|
||||
private readonly ILogger<ScrobbleWatcherJob> logger;
|
||||
|
@ -125,11 +125,11 @@ namespace Selector.Web
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseHttpsRedirection();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
app.UseHttpsRedirection();
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
//app.UseHsts();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Selector.Operations;
|
||||
using SpotifyAPI.Web;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Selector
|
||||
@ -40,9 +41,13 @@ namespace Selector
|
||||
{
|
||||
logger.LogInformation("Mapping Last.fm {} ({}) to Spotify", Query, QueryType);
|
||||
|
||||
var netTime = Stopwatch.StartNew();
|
||||
currentTask = searchClient.Item(new (QueryType, Query));
|
||||
currentTask.ContinueWith(async t =>
|
||||
{
|
||||
netTime.Stop();
|
||||
logger.LogTrace("Network request took {:n} ms", netTime.ElapsedMilliseconds);
|
||||
|
||||
if (t.IsCompletedSuccessfully)
|
||||
{
|
||||
HandleResponse(t);
|
@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Selector.Operations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -50,9 +51,14 @@ namespace Selector
|
||||
public Task Execute()
|
||||
{
|
||||
logger.LogInformation("Scrobble request #{} for {} by {} from {} to {}", pageNumber, username, pageSize, from, to);
|
||||
|
||||
var netTime = Stopwatch.StartNew();
|
||||
currentTask = userClient.GetRecentScrobbles(username, pagenumber: pageNumber, count: pageSize, from: from, to: to);
|
||||
currentTask.ContinueWith(async t =>
|
||||
{
|
||||
netTime.Stop();
|
||||
logger.LogTrace("Network request took {:n} ms", netTime.ElapsedMilliseconds);
|
||||
|
||||
if (t.IsCompletedSuccessfully)
|
||||
{
|
||||
var result = t.Result;
|
||||
|
Loading…
Reference in New Issue
Block a user