<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using RElmah.Foundation;
using RElmah.Models;

namespace RElmah.Queries.Frontend
{
    public class ErrorsFrontendQuery : IFrontendQuery
    {
        public async Task<IDisposable> Run(ValueOrError<User> user, RunTargets targets)
        {
            if (user.Value.Tokens.Count() > 1) return Disposable.Empty;

            var name = user.Value.Name;
            Func<Task<IEnumerable<Application>>> getUserApps = async () => await targets.DomainPersistor.GetUserApplications(name);

            var errors =
                from e in targets.ErrorsInbox.GetErrorsStream().Merge(targets.BackendErrorsInbox.GetErrorsStream())
                from apps in getUserApps()
                from a in apps
                where e.SourceId == a.Name
                select e;

            return errors
                .Subscribe(payload =>
                {
                    targets.FrontendNotifier.Error(name, payload);
                });
        }
    }
}<commit_msg>Null checks<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using RElmah.Common;
using RElmah.Foundation;
using RElmah.Models;

namespace RElmah.Queries.Frontend
{
    public class ErrorsFrontendQuery : IFrontendQuery
    {
        public async Task<IDisposable> Run(ValueOrError<User> user, RunTargets targets)
        {
            if (user.Value.Tokens.Count() > 1) return Disposable.Empty;

            var name = user.Value.Name;
            Func<Task<IEnumerable<Application>>> getUserApps = async () => await targets.DomainPersistor.GetUserApplications(name);

            var frontend = targets.ErrorsInbox != null 
                         ? targets.ErrorsInbox.GetErrorsStream() 
                         : Observable.Empty<ErrorPayload>();
            var backend  = targets.BackendErrorsInbox != null 
                         ? targets.BackendErrorsInbox.GetErrorsStream() 
                         : Observable.Empty<ErrorPayload>();
            var errors =
                from e in frontend.Merge(backend)
                from apps in getUserApps()
                from a in apps
                where e.SourceId == a.Name
                select e;

            return errors
                .Subscribe(payload =>
                {
                    targets.FrontendNotifier.Error(name, payload);
                });
        }
    }
}
{'fraction_non_alphanumeric': 0.086923370186809, 'fraction_numerical': 0.0007624857033930614, 'mean_word_length': 1.981818181818182, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2400770', 'n_tokens_mistral': 716, 'n_tokens_neox': 678, 'n_words': 147}