public async Task <ActionResult <List <string> > > GetAsync()
        {
            var search = new EntityValueSearch()
            {
                KeyLike = Keys.VariableKey + "%",
            };

            search.EntityIds.Add(-GetRequesterUid());

            var baseValues   = provider.GetQueryable <EntityValue>();
            var searchValues = provider.ApplyEntityValueSearch(baseValues, search);

            return(await provider.GetListAsync(searchValues.Select(x => x.key.Substring(Keys.VariableKey.Length))));
        }
Example #2
0
 public Task <List <long> > GetRevisionIdsAsync(long packageId)
 {
     return(provider.GetListAsync(
                from r in provider.GetQueryable <EntityRelation>()
                where r.entityId1 == packageId && r.type == Keys.HistoryRelation
                select r.entityId2));
 }
Example #3
0
        public async Task <List <SystemAggregate> > GetSystemAggregate(BaseSearch search)
        {
            var result = new List <SystemAggregate>();

            result.Add(new SystemAggregate()
            {
                id   = await provider.GetMaxAsync(provider.GetQueryable <EntityRelation>(), x => x.id),
                type = "actionMax"
            });
            result.Add(new SystemAggregate()
            {
                id   = await provider.GetMaxAsync(provider.GetQueryable <Entity>(), x => x.id),
                type = "contentMax"
            });
            result.Add(new SystemAggregate()
            {
                id   = await provider.GetMaxAsync(provider.GetQueryable <EntityValue>(), x => x.id),
                type = "valueMax"
            });
            return(result);
        }
        public async Task <List <EntityRelation> > ListenAsync(RelationListenConfig listenConfig, Requester requester, CancellationToken token)
        {
            var listenId = new RelationListener()
            {
                userId         = requester.userId,
                listenStatuses = listenConfig.statuses
            };

            var maxId = await provider.GetMaxAsync(provider.GetQueryable <EntityRelation>(), x => x.id);

            if (listenConfig.lastId <= 0)
            {
                listenConfig.lastId = maxId + listenConfig.lastId; //plus because negative
            }
            else if (maxId - listenConfig.lastId > 1000)
            {
                throw new BadRequestException($"LastID too far back! Perhaps restart your listener! System current max: {maxId}");
            }

            //This SERIOUSLY requires INTIMATE knowledge of how each of these systems works, like what entityId1 means etc.
            //That's bad.
            var results = await provider.ListenAsync <EntityRelation>(listenId, (q) =>
                                                                      q.Where(x =>
                                                                              (x.type == Keys.CommentHack ||
                                                                               x.type == Keys.WatchRelation && x.entityId1 == listenId.userId ||
                                                                               (x.type == Keys.WatchUpdate ||
                                                                                x.type == Keys.WatchDelete) && x.value.StartsWith($"{listenId.userId}_") ||
                                                                               x.type.StartsWith(Keys.ActivityKey) ||
                                                                               x.type.StartsWith(Keys.ModuleMessageKey) && (x.entityId2 == 0 || x.entityId2 == -requester.userId) ||
                                                                               x.type.StartsWith(Keys.CommentDeleteHack) ||
                                                                               x.type.StartsWith(Keys.CommentHistoryHack)) &&
                                                                              x.id > listenConfig.lastId),
                                                                      systemConfig.ListenTimeout, token);

            return(results);
        }
Example #5
0
 public IQueryable <X> Q <X>() where X : EntityBase
 {
     return(provider.GetQueryable <X>());
 }