refactors
This commit is contained in:
@@ -11,8 +11,8 @@ public sealed class JiboConditionedReply
|
||||
public string Reply { get; init; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class JiboExperienceCatalog
|
||||
{
|
||||
public sealed class JiboExperienceCatalog
|
||||
{
|
||||
public IReadOnlyList<string> Jokes { get; init; } = [];
|
||||
public IReadOnlyList<string> RobotFacts { get; init; } = [];
|
||||
public IReadOnlyList<string> HumanFacts { get; init; } = [];
|
||||
|
||||
@@ -518,9 +518,7 @@ public sealed class JiboInteractionService(
|
||||
randomizer,
|
||||
selected => RenderHolidayTemplate(selected, turn, greetingPresence),
|
||||
out var seasonalHolidayDecision))
|
||||
{
|
||||
return seasonalHolidayDecision;
|
||||
}
|
||||
|
||||
return semanticIntent switch
|
||||
{
|
||||
@@ -1682,10 +1680,7 @@ public sealed class JiboInteractionService(
|
||||
private string ChooseCommuteAppSetupReply(JiboExperienceCatalog catalog)
|
||||
{
|
||||
return SelectLegacyReply(
|
||||
catalog.CommuteAppSetupReplies,
|
||||
[
|
||||
"I need your commute settings before I can give you a commute report."
|
||||
]);
|
||||
catalog.CommuteAppSetupReplies, "I need your commute settings before I can give you a commute report.");
|
||||
}
|
||||
|
||||
private static string ChooseCommuteTemplate(
|
||||
@@ -2147,14 +2142,12 @@ public sealed class JiboInteractionService(
|
||||
"Your calendar says ${skill.calendar.eventSummaries.shift()}, ${skill.calendar.eventTimesOnAt.shift()}.");
|
||||
if (template.Contains("${skill.calendar.eventSummaries.shift()}", StringComparison.OrdinalIgnoreCase) ||
|
||||
template.Contains("${skill.calendar.eventTimesOnAt.shift()}", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return template
|
||||
.Replace("${skill.calendar.eventSummaries.shift()}", summary, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("${skill.calendar.eventTimesOnAt.shift()}", time, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("${speaker}", string.Empty, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace(" ", " ", StringComparison.Ordinal)
|
||||
.Trim();
|
||||
}
|
||||
|
||||
return $"Your calendar says {summary}, {time}.";
|
||||
}
|
||||
@@ -2171,7 +2164,8 @@ public sealed class JiboInteractionService(
|
||||
.Replace(" ", " ", StringComparison.Ordinal)
|
||||
.Trim();
|
||||
|
||||
return $"Looking at your calendar, there's nothing scheduled for the rest of the day today. Here's what's going on tomorrow: {snapshot.TomorrowEventSummaries[0]}.";
|
||||
return
|
||||
$"Looking at your calendar, there's nothing scheduled for the rest of the day today. Here's what's going on tomorrow: {snapshot.TomorrowEventSummaries[0]}.";
|
||||
}
|
||||
|
||||
return ChooseCalendarNothingReply(catalog);
|
||||
|
||||
@@ -333,7 +333,7 @@ internal static class PersonalReportOrchestrator
|
||||
reportText,
|
||||
"report-skill",
|
||||
BuildPersonalReportSkillPayload(reportText, weatherSkillPayload),
|
||||
ContextUpdates: BuildContextUpdates(
|
||||
BuildContextUpdates(
|
||||
IdleState,
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Jibo.Cloud.Application.Abstractions;
|
||||
using Jibo.Runtime.Abstractions;
|
||||
|
||||
namespace Jibo.Cloud.Application.Services;
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jibo.Cloud.Application.Abstractions;
|
||||
using Jibo.Runtime.Abstractions;
|
||||
|
||||
namespace Jibo.Cloud.Application.Services;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Jibo.Cloud.Application.Abstractions;
|
||||
using Jibo.Cloud.Domain.Models;
|
||||
using Jibo.Cloud.Infrastructure.Persistence;
|
||||
using Jibo.Runtime.Abstractions;
|
||||
|
||||
namespace Jibo.Cloud.Infrastructure.Calendar;
|
||||
@@ -31,9 +30,9 @@ public sealed class CloudStateCalendarReportProvider(ICloudStateStore cloudState
|
||||
|
||||
foreach (var entry in calendarEvents
|
||||
.Select(calendarEvent => (
|
||||
Summary: calendarEvent.Summary,
|
||||
calendarEvent.Summary,
|
||||
TimeLabel: calendarEvent.TimeLabel ?? "all day",
|
||||
Date: calendarEvent.Date))
|
||||
calendarEvent.Date))
|
||||
.Concat(ToCalendarEntries(holidays)))
|
||||
{
|
||||
if (entry.Date == today)
|
||||
@@ -65,11 +64,9 @@ public sealed class CloudStateCalendarReportProvider(ICloudStateStore cloudState
|
||||
IEnumerable<HolidayRecord> holidays)
|
||||
{
|
||||
foreach (var holiday in holidays)
|
||||
{
|
||||
yield return (
|
||||
holiday.Name,
|
||||
"all day",
|
||||
holiday.Date);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,8 @@ public sealed class CloudStateCommuteReportProvider(ICloudStateStore cloudStateS
|
||||
commute ??= commuteProfiles.FirstOrDefault(profile => profile.IsEnabled);
|
||||
|
||||
if (commute is null || !commute.IsComplete)
|
||||
{
|
||||
return Task.FromResult<CommuteReportSnapshot?>(
|
||||
new CommuteReportSnapshot(string.Empty, string.Empty, 0, RequiresSetup: true));
|
||||
}
|
||||
|
||||
var now = DateTimeOffset.Now;
|
||||
var workTarget = ResolveWorkTarget(now, commute);
|
||||
|
||||
@@ -338,16 +338,22 @@ public static class LegacyMimCatalogImporter
|
||||
CommuteConfirmSpeakerReplies = Merge(baseCatalog.CommuteConfirmSpeakerReplies,
|
||||
importedCatalog.CommuteConfirmSpeakerReplies),
|
||||
CommuteNowReplies = Merge(baseCatalog.CommuteNowReplies, importedCatalog.CommuteNowReplies),
|
||||
CommuteMinutesLeftReplies = Merge(baseCatalog.CommuteMinutesLeftReplies, importedCatalog.CommuteMinutesLeftReplies),
|
||||
CommuteMinutesLeftReplies = Merge(baseCatalog.CommuteMinutesLeftReplies,
|
||||
importedCatalog.CommuteMinutesLeftReplies),
|
||||
CommuteDepartTimeNormalReplies = Merge(baseCatalog.CommuteDepartTimeNormalReplies,
|
||||
importedCatalog.CommuteDepartTimeNormalReplies),
|
||||
CommuteDepartTimeNotNormalReplies = Merge(baseCatalog.CommuteDepartTimeNotNormalReplies,
|
||||
importedCatalog.CommuteDepartTimeNotNormalReplies),
|
||||
CommuteDriveNormalReplies = Merge(baseCatalog.CommuteDriveNormalReplies, importedCatalog.CommuteDriveNormalReplies),
|
||||
CommuteDriveLateReplies = Merge(baseCatalog.CommuteDriveLateReplies, importedCatalog.CommuteDriveLateReplies),
|
||||
CommuteDriveHurryReplies = Merge(baseCatalog.CommuteDriveHurryReplies, importedCatalog.CommuteDriveHurryReplies),
|
||||
CommuteDrivePoorReplies = Merge(baseCatalog.CommuteDrivePoorReplies, importedCatalog.CommuteDrivePoorReplies),
|
||||
CommuteDriveTerribleReplies = Merge(baseCatalog.CommuteDriveTerribleReplies, importedCatalog.CommuteDriveTerribleReplies),
|
||||
CommuteDriveNormalReplies = Merge(baseCatalog.CommuteDriveNormalReplies,
|
||||
importedCatalog.CommuteDriveNormalReplies),
|
||||
CommuteDriveLateReplies =
|
||||
Merge(baseCatalog.CommuteDriveLateReplies, importedCatalog.CommuteDriveLateReplies),
|
||||
CommuteDriveHurryReplies =
|
||||
Merge(baseCatalog.CommuteDriveHurryReplies, importedCatalog.CommuteDriveHurryReplies),
|
||||
CommuteDrivePoorReplies =
|
||||
Merge(baseCatalog.CommuteDrivePoorReplies, importedCatalog.CommuteDrivePoorReplies),
|
||||
CommuteDriveTerribleReplies = Merge(baseCatalog.CommuteDriveTerribleReplies,
|
||||
importedCatalog.CommuteDriveTerribleReplies),
|
||||
CommuteTransportNormalReplies = Merge(baseCatalog.CommuteTransportNormalReplies,
|
||||
importedCatalog.CommuteTransportNormalReplies),
|
||||
CommuteTransportLateReplies = Merge(baseCatalog.CommuteTransportLateReplies,
|
||||
@@ -529,6 +535,7 @@ public static class LegacyMimCatalogImporter
|
||||
|
||||
private sealed class LegacyMimCatalogBuilder
|
||||
{
|
||||
private readonly List<string> _birthdayCelebrationReplies = [];
|
||||
private readonly List<string> _calendarNothingReplies = [];
|
||||
private readonly List<string> _calendarNothingTodayReplies = [];
|
||||
private readonly List<string> _calendarOutroReplies = [];
|
||||
@@ -537,28 +544,27 @@ public static class LegacyMimCatalogImporter
|
||||
private readonly List<string> _commuteConfirmSpeakerReplies = [];
|
||||
private readonly List<string> _commuteDepartTimeNormalReplies = [];
|
||||
private readonly List<string> _commuteDepartTimeNotNormalReplies = [];
|
||||
private readonly List<string> _commuteNowReplies = [];
|
||||
private readonly List<string> _commuteMinutesLeftReplies = [];
|
||||
private readonly List<string> _commuteDriveNormalReplies = [];
|
||||
private readonly List<string> _commuteDriveLateReplies = [];
|
||||
private readonly List<string> _commuteDriveHurryReplies = [];
|
||||
private readonly List<string> _commuteDriveLateReplies = [];
|
||||
private readonly List<string> _commuteDriveNormalReplies = [];
|
||||
private readonly List<string> _commuteDrivePoorReplies = [];
|
||||
private readonly List<string> _commuteDriveTerribleReplies = [];
|
||||
private readonly List<string> _commuteTransportNormalReplies = [];
|
||||
private readonly List<string> _commuteTransportLateReplies = [];
|
||||
private readonly List<string> _commuteTransportHurryReplies = [];
|
||||
private readonly List<string> _commuteMinutesLeftReplies = [];
|
||||
private readonly List<string> _commuteNowReplies = [];
|
||||
private readonly List<string> _commuteServiceDownReplies = [];
|
||||
private readonly List<string> _birthdayCelebrationReplies = [];
|
||||
private readonly List<string> _commuteTransportHurryReplies = [];
|
||||
private readonly List<string> _commuteTransportLateReplies = [];
|
||||
private readonly List<string> _commuteTransportNormalReplies = [];
|
||||
private readonly List<JiboConditionedReply> _emotionReplies = [];
|
||||
private readonly List<string> _fallbacks = [];
|
||||
private readonly List<string> _funFacts = [];
|
||||
private readonly List<string> _favoriteAnimalReplies = [];
|
||||
private readonly List<string> _funFacts = [];
|
||||
private readonly List<string> _greetings = [];
|
||||
private readonly List<string> _holidayGiftReplies = [];
|
||||
private readonly List<string> _holidayGreetingReplies = [];
|
||||
private readonly List<string> _holidayReplies = [];
|
||||
private readonly List<string> _holidaySeasonReplies = [];
|
||||
private readonly List<string> _holidayTrackerReplies = [];
|
||||
private readonly List<string> _greetings = [];
|
||||
private readonly List<string> _howAreYous = [];
|
||||
private readonly List<string> _humanFacts = [];
|
||||
private readonly List<string> _jokes = [];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Jibo.Cloud.Application.Abstractions;
|
||||
using Jibo.Cloud.Domain.Models;
|
||||
@@ -9,6 +10,7 @@ public sealed class NagerDateHolidayCalendarProvider : IHolidayCalendarProvider
|
||||
{
|
||||
private static readonly HttpClient HttpClient = new();
|
||||
private static readonly ConcurrentDictionary<string, HolidayRecord[]> Cache = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web)
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
@@ -168,13 +170,13 @@ public sealed class NagerDateHolidayCalendarProvider : IHolidayCalendarProvider
|
||||
var l = (32 + 2 * e + 2 * i - h - k) % 7;
|
||||
var m = (a + 11 * h + 22 * l) / 451;
|
||||
var month = (h + l - 7 * m + 114) / 31;
|
||||
var day = ((h + l - 7 * m + 114) % 31) + 1;
|
||||
var day = (h + l - 7 * m + 114) % 31 + 1;
|
||||
return new DateOnly(year, month, day);
|
||||
}
|
||||
|
||||
private static string Slugify(string value)
|
||||
{
|
||||
var builder = new System.Text.StringBuilder(value.Length);
|
||||
var builder = new StringBuilder(value.Length);
|
||||
var lastWasDash = false;
|
||||
foreach (var ch in value.ToLowerInvariant())
|
||||
{
|
||||
|
||||
@@ -18,22 +18,23 @@ public sealed class InMemoryCloudStateStore : ICloudStateStore
|
||||
};
|
||||
|
||||
private readonly List<BackupRecord> _backups = [];
|
||||
private readonly List<CommuteProfileRecord> _commuteProfiles = [];
|
||||
private readonly List<CalendarEventRecord> _calendarEvents = [];
|
||||
private readonly List<CommuteProfileRecord> _commuteProfiles = [];
|
||||
private readonly ConcurrentDictionary<string, DeviceRegistration> _devices = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly IHolidayCalendarProvider _holidayCalendarProvider;
|
||||
private readonly List<HolidayRecord> _holidayOverrides = [];
|
||||
|
||||
private readonly ConcurrentDictionary<string, KeyRequestRecord>
|
||||
_keyRequests = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly List<LoopRecord> _loops;
|
||||
private readonly List<HolidayRecord> _holidayOverrides = [];
|
||||
private readonly List<MediaRecord> _media = [];
|
||||
private readonly List<PersonRecord> _people;
|
||||
|
||||
private readonly ConcurrentDictionary<string, CloudSession>
|
||||
_sessionsByToken = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly IHolidayCalendarProvider _holidayCalendarProvider;
|
||||
private readonly ISnapshotStore _snapshotStore;
|
||||
private readonly ConcurrentDictionary<string, string> _symmetricKeys = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Lock _syncRoot = new();
|
||||
@@ -515,7 +516,8 @@ public sealed class InMemoryCloudStateStore : ICloudStateStore
|
||||
{
|
||||
Id = normalizedId,
|
||||
LoopId = resolvedLoopId,
|
||||
Summary = string.IsNullOrWhiteSpace(calendarEvent.Summary) ? "Calendar event" : calendarEvent.Summary.Trim(),
|
||||
Summary =
|
||||
string.IsNullOrWhiteSpace(calendarEvent.Summary) ? "Calendar event" : calendarEvent.Summary.Trim(),
|
||||
TimeLabel = string.IsNullOrWhiteSpace(calendarEvent.TimeLabel) ? null : calendarEvent.TimeLabel.Trim(),
|
||||
Date = calendarEvent.Date,
|
||||
EndDate = calendarEvent.EndDate,
|
||||
@@ -757,14 +759,12 @@ public sealed class InMemoryCloudStateStore : ICloudStateStore
|
||||
private void EnsureDefaultTopology()
|
||||
{
|
||||
if (_loops.Count == 0)
|
||||
{
|
||||
_loops.Add(new LoopRecord
|
||||
{
|
||||
OwnerAccountId = _account.AccountId,
|
||||
RobotId = _robot.RobotId,
|
||||
RobotFriendlyId = _robot.DeviceId
|
||||
});
|
||||
}
|
||||
|
||||
if (_people.Count != 0)
|
||||
{
|
||||
|
||||
@@ -4289,5 +4289,4 @@ public sealed class JiboInteractionServiceTests
|
||||
return Task.FromResult(Snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user