Example #1
0
        private async Task <IEnumerable <NotesData> > FilterModifiedNodesAsync(string guid, List <NotesData> notes, HashSet <int> tagIds, Throttle throttle, ProgressData progressData)
        {
            progressData.Reset("Filtering notes", notes.Count);
            var tasks = notes.Select(async note =>
            {
                var match = await _matchesRetriever.GetMatchAsync(guid, note.TestId, tagIds, throttle, progressData);
                if (match?.TestGuid == null)
                {
                    return(null);
                }

                note.OldNotes   = match.Note;
                note.OldStarred = match.Starred;
                note.OldTags    = match.TagIds ?? new List <int>();
                return((
                           note.OldNotes != note.NewNotes ||
                           (note.NewStarred != null && note.OldStarred != note.NewStarred) ||
                           note.NewTags.Except(note.OldTags).Any() ||
                           note.NewTagsRemoved.Intersect(note.OldTags).Any()
                           ) ? note : null);
            });
            var notesToUpdate = await Task.WhenAll(tasks);

            return(notesToUpdate.Where(note => note != null));
        }
Example #2
0
        private async Task <IEnumerable <NotesData> > FilterModifiedNodesAsync(string guid, List <NotesData> notes, Throttle throttle, ProgressData progressData)
        {
            progressData.Reset("Filtering notes", notes.Count);
            var tasks = notes.Select(async note =>
            {
                var match     = await _matchesRetriever.GetMatchAsync(guid, note.TestId, throttle, progressData);
                note.OldNotes = match?.Note;
                return((match != null && match.Note != note.NewNotes) ? note : null);
            });
            var notesToUpdate = await Task.WhenAll(tasks);

            return(notesToUpdate.Where(note => note != null));
        }