Skip to content

Commit

Permalink
Merge branch 'main' into task/Export-encription-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
john-s-morgan committed May 8, 2023
2 parents 083b8ff + d632cbb commit 23ebd2f
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ bindings/netstandard/ElectionGuard/*.user
lint-results.xml

database/
!src/electionguard-ui/ElectionGuard.UI.Lib/Services/Database

node_modules/

Expand Down
23 changes: 21 additions & 2 deletions src/electionguard-db/mongo-init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
db.createCollection("key_ceremonies");
db.key_ceremonies.createIndex({ completed_at: 1 });
db.key_ceremonies.createIndex({ key_ceremony_name: 1 });
db.createCollection("elections");
db.createCollection("ballots");
db.createCollection("tallies");

db.key_ceremonies.createIndex({ KeyCeremonyId: 1, DataType: 1 });
db.key_ceremonies.createIndex({ KeyCeremonyId: 1, DesignatedId: 1, DataType: 1 });
db.key_ceremonies.createIndex({ KeyCeremonyId: 1, GuardianId: 1, DataType: 1 });
db.key_ceremonies.createIndex({ State: 1, DataType: 1 });

db.elections.createIndex({ ElectionId: 1, DataType: 1 });
db.elections.createIndex({ Name: 1, DataType: 1 });

db.ballots.createIndex({ ElectionId: 1, DataType: 1 });
db.ballots.createIndex({ UploadId: 1, DataType: 1 });
db.ballots.createIndex({ BallotCode: 1, DataType: 1 });
db.ballots.createIndex({ SerialNumber: 1, ElectionId: 1, DataType: 1 });

db.tallies.createIndex({ Name: 1, DataType: 1 });
db.tallies.createIndex({ ElectionId: 1, DataType: 1 });
db.tallies.createIndex({ TallyId: 1, DataType: 1 });
db.tallies.createIndex({ State: 1, DataType: 1 });
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,12 @@ public async Task<bool> BallotExists(string ballotCode)
}

/// <summary>
/// Check to see if the ballot has already been included
/// Get a ballot based on its ballot code
/// </summary>
/// <param name="ballotCode">ballotcode to find</param>
public async Task<bool> GetByBallotCodeAsync(string ballotCode)
public async Task<BallotRecord?> GetByBallotCodeAsync(string ballotCode)
{
var filterBuilder = Builders<BallotRecord>.Filter;
var filter = filterBuilder.And(filterBuilder.Eq(Constants.BallotCode, ballotCode));

var ballotCount = await CountByFilterAsync(filter);
return ballotCount > 0;
return await GetByFieldAsync(Constants.BallotCode, ballotCode);
}

/// <summary>
Expand All @@ -73,5 +69,4 @@ public async Task DeleteByBallotCodeAsync(string ballotCode)

await MarkAsDeletedAsync(filter);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ public async Task<bool> DriveUsed(long serialNumber, string electionId)
var uploadCount = await CountByFilterAsync(filter);
return uploadCount > 0;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ElectionGuard.UI.Lib.Models;
using MongoDB.Driver;

namespace ElectionGuard.UI.Lib.Services;

Expand All @@ -26,5 +25,4 @@ public class CiphertextTallyService : BaseDatabaseService<CiphertextTallyRecord>
{
return await GetByFieldAsync(Constants.TallyId, tallyId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public class ConstantsService : BaseDatabaseService<ConstantsRecord>
{
return await GetByFieldAsync(Constants.ElectionId, electionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public class ContextService : BaseDatabaseService<ContextRecord>
{
return await GetByFieldAsync(Constants.ElectionId, electionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ public static bool Ping()
}

var server = client.Cluster.Description.Servers.FirstOrDefault();
return (
return
server is not null &&
server.HeartbeatException is null &&
server.State == ServerState.Connected
);
server.State == ServerState.Connected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ public async Task<long> CountAsync(string keyCeremonyId, string guardianId)

return await CountByFilterAsync(filter);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,4 @@ public async Task<long> CountAsync(string keyCeremonyId)
var list = await GetAllByFilterAsync(filter);
return list.FirstOrDefault();
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ElectionGuard.UI.Lib.Models;
using MongoDB.Driver;

namespace ElectionGuard.UI.Lib.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ElectionGuard.UI.Lib.Models;
using MongoDB.Driver;

namespace ElectionGuard.UI.Lib.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ElectionGuard.UI.Lib.Models;
using MongoDB.Driver;

namespace ElectionGuard.UI.Lib.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,4 @@ virtual public async Task UpdateCompleteAsync(string tallyId)

await UpdateAsync(filter, update);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,4 @@ public async Task<long> CountAsync(string keyCeremonyId)

return await CountByFilterAsync(filter);
}


}

0 comments on commit 23ebd2f

Please sign in to comment.