Skip to content

Commit

Permalink
Fixing polarity
Browse files Browse the repository at this point in the history
  • Loading branch information
synhershko committed Sep 30, 2014
1 parent fa02e4e commit 103bf1a
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RavenTimeoutPersistence : IPersistTimeouts
public RavenTimeoutPersistence(IDocumentStore store)
{
this.store = store;

store.DatabaseCommands.PutIndex("RavenTimeoutPersistence/TimeoutDataSortedByTime",
new IndexDefinitionBuilder<TimeoutData>
{
Expand All @@ -40,15 +40,15 @@ public RavenTimeoutPersistence(IDocumentStore store)
{doc => doc.Time, FieldStorage.No}
}
}, true);

store.DatabaseCommands.PutIndex("RavenTimeoutPersistence/TimeoutData/BySagaId", new IndexDefinitionBuilder<TimeoutData>
{
Map = docs => from doc in docs
select new { doc.SagaId }
}, true);

TriggerCleanupEvery = TimeSpan.FromMinutes(2);
CleanupGapFromTimeslice = TimeSpan.FromMinutes(1);
CleanupGapFromTimeslice = TimeSpan.FromMinutes(1);
}

private static IRavenQueryable<TimeoutData> GetChunkQuery(IDocumentSession session)
Expand Down Expand Up @@ -92,7 +92,7 @@ public List<Tuple<string, DateTime>> GetNextChunk(DateTime startSlice, out DateT
// Allow for occasionally cleaning up old timeouts for edge cases where timeouts have been
// added after startSlice have been set to a later timout and we might have missed them
// because of stale indexes.
if (lastCleanupTime.Add(TriggerCleanupEvery) > now || lastCleanupTime == DateTime.MinValue)
if (lastCleanupTime.Add(TriggerCleanupEvery) < now || lastCleanupTime == DateTime.MinValue)
{
results.AddRange(GetCleanupChunk(startSlice));
}
Expand All @@ -106,12 +106,12 @@ public List<Tuple<string, DateTime>> GetNextChunk(DateTime startSlice, out DateT
{
session.Advanced.AllowNonAuthoritativeInformation = true;

var query = GetChunkQuery(session)
.Where(
t =>
t.Time > startSlice &&
t.Time <= now)
.Select(t => new { t.Id, t.Time })
var query = GetChunkQuery(session)
.Where(
t =>
t.Time > startSlice &&
t.Time <= now)
.Select(t => new { t.Id, t.Time })
.Statistics(out stats);
do
{
Expand Down Expand Up @@ -197,7 +197,7 @@ public bool TryRemove(string timeoutId, out TimeoutData timeoutData)
public void RemoveTimeoutBy(Guid sagaId)
{
using (var session = OpenSession())
{
{
var items = session.Query<TimeoutData>("RavenTimeoutPersistence/TimeoutData/BySagaId").Where(x => x.SagaId == sagaId);
foreach (var item in items)
session.Delete(item);
Expand Down

0 comments on commit 103bf1a

Please sign in to comment.