Commit 4b35f4ce authored by Clint.Network's avatar Clint.Network

Fix Lottery Service and Add Iterator to Draw

parent bf849588
......@@ -9,5 +9,6 @@ namespace Stratis.Guru.Models
public ObjectId Id { get; set; }
public long DrawDate { get; set; }
public bool Passed { get; set; }
public uint BeginIterator { get; set; }
}
}
\ No newline at end of file
......@@ -12,10 +12,12 @@ namespace Stratis.Guru.Models
public class Draws : IDraws
{
private DatabaseContext _databaseContext;
private ISettings _settings;
public Draws(DatabaseContext databaseContext)
public Draws(DatabaseContext databaseContext, ISettings settings)
{
_databaseContext = databaseContext;
_settings = settings;
}
public string GetLastDraw()
......@@ -30,6 +32,7 @@ namespace Stratis.Guru.Models
await _databaseContext.Draws.InsertOneAsync(new Draw()
{
DrawDate = nextDrawTimestamp,
BeginIterator = _settings.GetIterator(),
Passed = false
});
}
......
......@@ -39,7 +39,7 @@ namespace Stratis.Guru.Services
await InitLotteryAsync();
await CalculateNextDrawAsync();
_updateTimer.Interval = 10;
_updateTimer.Interval = TimeSpan.FromMinutes(5).TotalMilliseconds;
_updateTimer.Enabled = true;
_updateTimer.Elapsed += async (sender, args) =>
{
......@@ -72,10 +72,9 @@ namespace Stratis.Guru.Services
private async Task CalculateNextDrawAsync()
{
DateTime today = DateTime.UtcNow;
DateTime today = DateTime.UtcNow.Date;
int daysUntilFriday = ((int)DayOfWeek.Friday - (int)today.DayOfWeek + 7) % 7;
_nextDraw = today.AddDays(daysUntilFriday);
//_nextDraw = DateTime.UtcNow;
var nextDrawTimestamp = ((DateTimeOffset)_nextDraw).ToUnixTimeSeconds();
......
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