change code to only check the time log gap if the card is associated to a user.
This will ensure that multiple new users swiping their cards will definitely be added to the system. #41
This commit is contained in:
parent
1560623460
commit
fa38512c9a
@ -351,18 +351,21 @@ namespace SQLiteRepository
|
||||
var logDirection = GetLogDirection(ident.UserId_FK);
|
||||
|
||||
#region Check the user hasnt registered an event in the last few minutes..
|
||||
//BUG: what happens if unassociated cards are swiped within the threshold? need to get all of them.
|
||||
var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3");
|
||||
var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes);
|
||||
var logs = _connection.Query<TimeLogDb>(
|
||||
SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES,
|
||||
threshold.Ticks, ident.UserId_FK);
|
||||
_logger.Trace("Checking last swipe event gap");
|
||||
if (logs.Any())
|
||||
{
|
||||
_logger.Error("Not logging event for user id: {0}, logged event within TimeGap Threshold of {1}", ident.UserId_FK, threshold);
|
||||
logId = -1;
|
||||
return OperationResponse.FAILED;
|
||||
|
||||
if (ident.UserId_FK!=-1)
|
||||
{ //only check log gap if the card is associated to a user
|
||||
var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3");
|
||||
var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes);
|
||||
var logs = _connection.Query<TimeLogDb>(
|
||||
SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES,
|
||||
threshold.Ticks, ident.UserId_FK);
|
||||
_logger.Trace("Checking last swipe event gap");
|
||||
if (logs.Any())
|
||||
{
|
||||
_logger.Error("Not logging event for user id: {0}, logged event within TimeGap Threshold of {1}", ident.UserId_FK, threshold);
|
||||
logId = -1;
|
||||
return OperationResponse.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user