fixed minuser calculations
This commit is contained in:
parent
715b14ecc5
commit
6d6e720695
3 changed files with 8 additions and 8 deletions
|
@ -308,8 +308,7 @@ namespace Lieb.Data
|
||||||
public static ApiRaid ConvertRaid(Raid raid)
|
public static ApiRaid ConvertRaid(Raid raid)
|
||||||
{
|
{
|
||||||
string title = raid.Title;
|
string title = raid.Title;
|
||||||
if (raid.SignUps.Count < raid.MinUsers
|
if (!raid.HasEnoughUsers && raid.MinUserDeadLineUTC.UtcDateTime < DateTimeOffset.UtcNow)
|
||||||
&& raid.MinUserDeadLineUTC.UtcDateTime > DateTimeOffset.UtcNow)
|
|
||||||
{
|
{
|
||||||
title = $"The raid was canceled because of not enough sign ups.\n\n{raid.Title}";
|
title = $"The raid was canceled because of not enough sign ups.\n\n{raid.Title}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,8 +468,7 @@ namespace Lieb.Data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raid.SignUps.Count < raid.MinUsers
|
if (!raid.HasEnoughUsers && raid.MinUserDeadLineUTC < DateTimeOffset.UtcNow)
|
||||||
&& raid.MinUserDeadLineUTC < DateTimeOffset.UtcNow)
|
|
||||||
{
|
{
|
||||||
errorMessage = $"The raid was canceled because of not enough sign ups.";
|
errorMessage = $"The raid was canceled because of not enough sign ups.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -700,8 +699,8 @@ namespace Lieb.Data
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
List<Raid> raids = context.Raids
|
List<Raid> raids = context.Raids
|
||||||
.Include(r => r.SignUps)
|
.Include(r => r.SignUps)
|
||||||
.Where(r => r.SignUps.Count < r.MinUsers && r.MinUserPollId == null).ToList();
|
.Where(r => r.MinUserPollId == null).ToList();
|
||||||
foreach (Raid raid in raids.Where(r => r.MinUserDeadLineUTC < DateTimeOffset.UtcNow && r.StartTimeUTC > DateTimeOffset.UtcNow))
|
foreach (Raid raid in raids.Where(r => !r.HasEnoughUsers && r.MinUserDeadLineUTC < DateTimeOffset.UtcNow && r.StartTimeUTC > DateTimeOffset.UtcNow))
|
||||||
{
|
{
|
||||||
raid.MinUserPollId = await _pollService.CreatePoll(
|
raid.MinUserPollId = await _pollService.CreatePoll(
|
||||||
"The raid has not the required users, do you want to raid anyway?",
|
"The raid has not the required users, do you want to raid anyway?",
|
||||||
|
@ -716,8 +715,8 @@ namespace Lieb.Data
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
List<Raid> raids = context.Raids
|
List<Raid> raids = context.Raids
|
||||||
.Include(r => r.SignUps)
|
.Include(r => r.SignUps)
|
||||||
.Where(r => r.SignUps.Count < r.MinUsers && r.MinUserPollId != null).ToList();
|
.Where(r => r.MinUserPollId != null).ToList();
|
||||||
foreach (Raid raid in raids.Where(r => r.MinUserDeadLineUTC < DateTimeOffset.UtcNow && r.StartTimeUTC > DateTimeOffset.UtcNow))
|
foreach (Raid raid in raids.Where(r => !r.HasEnoughUsers && r.MinUserDeadLineUTC < DateTimeOffset.UtcNow && r.StartTimeUTC > DateTimeOffset.UtcNow))
|
||||||
{
|
{
|
||||||
Poll poll = _pollService.GetPoll(raid.MinUserPollId.Value);
|
Poll poll = _pollService.GetPoll(raid.MinUserPollId.Value);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
|
|
||||||
public ICollection<RaidSignUp> SignUps { get; set; } = new HashSet<RaidSignUp>();
|
public ICollection<RaidSignUp> SignUps { get; set; } = new HashSet<RaidSignUp>();
|
||||||
|
|
||||||
|
public bool HasEnoughUsers {get{ return SignUps.Where(s => s.SignUpType != SignUpType.SignedOff && s.SignUpType != SignUpType.Flex).Count() >= this.MinUsers;}}
|
||||||
|
|
||||||
public Raid() { }
|
public Raid() { }
|
||||||
|
|
||||||
public Raid(RaidTemplate template) : base(template, template.TimeZone, true)
|
public Raid(RaidTemplate template) : base(template, template.TimeZone, true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue