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