uprtcl / js-uprtcl-server

Uprtcl JS web-server service provider

Home Page:http://uprtcl.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "forks" flag to search

pepoospina opened this issue · comments

commented

Add a forks flag that will extend the filtered intermediate result to also (independent) forks of the matched perspective.

I'm not sure if this is entirely possible in general, but it does fit very well if we reconsider the getOtherIndpPerspectives as a explore case with under = perspectiveId, and a forks in SearchOptions being true.

This is why maybe it is just a special case of search function.

commented

I tried to make a patch and connect the getIndependentPerspectives function into the current fetchPerspectives one as a "special" case when forks option is provided, (setting level = 0).

here is what I did (all three repos)
https://github.com/uprtcl/js-uprtcl-dev/tree/get-block-forks

But the forks are not being detected. We should check this together @sotous

@pepoospina I modified the schema in order to be able to "reverse" the context.

This enable us to have a more friendly query at the time of looking for independent perspectives, this is how the new DQL will look:

perspectiveRef as var(func: eq(xid, ${perspectiveId})) { 
    context {
      targetCon as uid
    }
    parents: ~children {
      context {
        parentContext as uid
      }
    }
  }

    // Verify indepent perspectives criteria with parents
    normalRef(func: uid(targetCon)) {
       normalPersps: ~context @filter(
         not(uid(perspectiveRef))
        ) @cascade {
          normalIds: xid
          ~children {
            context @filter(not(uid(parentContext)))
          }
        }

   // Verify indepent perspectives criteria without parents
  orphanRef(func: uid(targetCon)) {
      orphanPersps: ~context @filter(
        not(uid(perspectiveRef))
        AND
        eq(count(~children), 0)
       ) @cascade {
         orphanIds: xid
       }

However, I still need to add permission checks as well.

Permissions checks have been added. This can be tested and seen here:

https://github.com/uprtcl/js-uprtcl-dev/tree/get-block-forks-sotous

Latest updates about the feature can be seen here:

https://github.com/uprtcl/js-uprtcl-dev/tree/get-block-forks-sotous