예제 #1
0
        public override string GetFirstByLowestScoreFromSet(string key, double fromScore, double toScore)
        {
            if (!_queues.Any())
            {
                return(null);
            }

            var id = _postgreSqlConnection.GetFirstByLowestScoreFromSet(key, fromScore, toScore);

            if (_queues == null || id == null)
            {
                return(id);
            }

            var recurringJobId = key switch
            {
                "recurring-jobs" => id,
                "schedule" => _postgreSqlConnection.GetJobParameter(id, "RecurringJobId")?.Replace("\"", ""),
                _ => throw new InvalidOperationException($"{key} is not a recognized job type")
            };

            var queue = recurringJobId switch
            {
                null => "default",
                _ => _postgreSqlConnection.GetValueFromHash($"recurring-job:{recurringJobId}", "Queue") ?? "default"
            };

            return(_queues.Contains(queue) ? id : null);

            // return id.Where(id =>
            //     {
            //         string? recurringJobId = key switch
            //         {
            //             "recurring-jobs" => id,
            //             "schedule" => _postgreSqlConnection.GetJobParameter(id, "RecurringJobId")?.Replace("\"", ""),
            //             _ => throw new InvalidOperationException($"{key} is not a recognized job type")
            //         };
            //
            //         string queue = recurringJobId switch
            //         {
            //             null => "default",
            //             _ => _postgreSqlConnection.GetValueFromHash($"recurring-job:{recurringJobId}", "Queue") ?? "default"
            //         };
            //
            //         return _queues.Contains(queue);
            //     }).SingleOrDefault<string>();
            //return _postgreSqlConnection.GetFirstByLowestScoreFromSet(key, fromScore, toScore);
        }
예제 #2
0
 public override string GetFirstByLowestScoreFromSet(string key, double fromScore, double toScore)
 {
     return(_sqlServerConnection.GetFirstByLowestScoreFromSet(key, fromScore, toScore));
 }