ksivasenthil / PingMe

Ping Me Application for private messaging and communication
1 stars 0 forks source link

Ping a message from Ping history #3

Open ksivasenthil opened 9 years ago

ksivasenthil commented 9 years ago

Given I have selected a target to ping As a pinger I should be allowed to create a new message and ping the target So that I could send a new message to a target pinger and add to the ping history.

ksivasenthil commented 9 years ago

I can call this done if the refactoring is done on the server code as well.

ksivasenthil commented 9 years ago

Currently in WorkerProcess.cs, both incoming and outgoing list are built separately. Then using a nested foreach loop the relevant ones are picked from the only incoming list. Following code hints on the possible optimization -

IEnumerable<..>outGoingList = Storage.Where(outgoingCriteria)...;
List<string> outGoingDestination = outGoingList.Select(d=>d.Key).ToList();
//This query is optimized by having additional where criteria. Otherwise, the Storage would be 
// queried all over again.
IEnumerable<..>inComingList = Storage.Where(inComingCriteria).Where(d=> !outGoingDestination.Contains(d.Source)).OrderBy<...>(..).GroupBy<..>(..);

//Merge the two IEnumerables
conversationRoot = outGoingList.Concat<..>(inComingList);

//Build the list to desired type
return BuildList(conversationRoot, source, ..);