Commit 8b230f57 authored by HankG's avatar HankG

Add interim timeline management (no tests implemented)

parent f76b4726
Pipeline #98107272 failed with stage
in 60 minutes and 1 second
using System;
using System.Collections.Generic;
using System.Linq;
using MySocialPortalDesktop.Factory;
using MySocialPortalLib.Model;
using MySocialPortalLib.Repository;
namespace MySocialPortalLib.Service
{
public class TimelineManagementService
{
private const int QueryPaddingMinutes = 1;
private const int QueryWindowDays = 1;
public ulong EarliestValue { get; }
public ulong LatestValue { get; }
public ulong ForwardValue { get; }
private TimelineManagementService()
{
throw new MethodAccessException();
}
public TimelineManagementService(ITimelineRepository repository, ulong earliestValue, ulong latestValue, ulong forwardValue)
{
TimelineRepository = repository;
EarliestValue = earliestValue;
LatestValue = latestValue;
ForwardValue = forwardValue;
}
public TimelineInterval? GetNextSamplingIntervals(string timelineName)
{
if (TimelineRepository.CountByTimelineName(timelineName) == 0)
{
var interval = new TimelineInterval
{
IntervalStart = EarliestValue,
IntervalStop = ForwardValue,
TimelineName = timelineName
};
TimelineRepository.AddOrUpdate(interval);
return interval;
}
var intervals = new List<TimelineInterval>(TimelineRepository.FindByTimelineName(timelineName));
intervals.Sort((i1, i2) => -i1.IntervalStop.CompareTo(i2.IntervalStop));
var interval2 = new TimelineInterval
{
IntervalStart = intervals[0].IntervalStop,
IntervalStop = ForwardValue,
TimelineName = timelineName
};
TimelineRepository.AddOrUpdate(interval2);
return interval2;
}
public bool UpdateRequestedInterval(TimelineInterval updatedInterval)
{
return TimelineRepository.FindById(updatedInterval.Id) != null
&& TimelineRepository.AddOrUpdate(updatedInterval);
}
private ITimelineRepository TimelineRepository { get; }
}
}
\ No newline at end of file
using System;
using Xunit;
namespace MySocialPortalLibTest.Service
{
public class TimelineManagementServiceTest
{
[Fact]
public void TestConstruction()
{
throw new NotImplementedException();
}
[Fact]
public void TestMarchingForwardOnly()
{
//simple test starts from blank, creates initial sample and always marches forward always filling
throw new NotImplementedException();
}
[Fact]
public void TestMarchingForwardGaps()
{
//test marches forward but creates gaps, simulating when window size isn't filled by the whole query
throw new NotImplementedException();
}
[Fact]
public void TestMarchingForwardGapsBackfill()
{
//test marches forward but creates gaps, but filling them in marching backwards
throw new NotImplementedException();
}
[Fact]
public void TestGapForwardRandomFill()
{
//Simulates a marching forward in time creating gaps and then randomly filling in the gaps
//may want to simulate overfill
throw new NotImplementedException();
}
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment