Searching for Applicants should work

This commit is contained in:
Rick Falkvinge
2018-03-08 13:26:26 +01:00
parent 053e83ed1b
commit 4471e0b6b2
9 changed files with 193 additions and 17 deletions
+50
View File
@@ -103,6 +103,56 @@ namespace Swarmops.Database
}
}
public Dictionary<int, List<BasicApplicant>> GetApplicantsFromPeople(int[] personIds)
{
Dictionary<int, List<BasicApplicant>> result = new Dictionary<int, List<BasicApplicant>>();
if (personIds == null || personIds.Length == 0)
{
return result;
}
// Optimization: If more than 128 personIds, build a hash table, get _all_ memberships, and return
// the matching ones logic wise. We've had _queries_ that exceed 64k text in length...
/*
if (personIds.Length > 128)
{
return GetParticipationsForPeopleOptimizedForLargeSets(personIds, gracePeriod);
}*/
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
string commandString = "SELECT " + applicantFieldSequence + " WHERE "
+ "Open=1 AND PersonId in (" + JoinIds(personIds) + ")";
DbCommand command = GetDbCommand(commandString, connection);
command.CommandTimeout = 30; // If 30s is too short, something needs optimization.
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
BasicApplicant applicant = ReadApplicantFromDataReader(reader);
int personId = applicant.PersonId;
if (!result.ContainsKey(personId))
{
result[personId] = new List<BasicApplicant>();
}
result[personId].Add(applicant);
// Add to this person's list of memberships
}
}
}
return result;
}
#endregion
#region Creation and manipulation - stored procedures
+1 -1
View File
@@ -306,7 +306,7 @@ namespace Swarmops.Database
result[personId] = new List<BasicParticipation>();
}
result[personId].Add (ReadMembershipFromDataReader (reader));
result[personId].Add (participation);
// Add to this person's list of memberships
}
}