Greenstand / treetracker-functions

The functions to deploy to Greenstand FAAS
0 stars 8 forks source link

Build two openfaas function to test these two SQL #1

Open dadiorchen opened 1 year ago

dadiorchen commented 1 year ago

We aready setup our openfaas by https://github.com/Greenstand/treetracker-infrastructure/pull/172 To finish this function, we need to setup the db connection with openfaas

We need to create two functions that request our test postgresqlDB and return the result, these two SQLs are here:

SQL 1:

select * from trees
where
(
  planting_organization_id in (select entity_id from getEntityRelationshipChildren(194))
)
order by id desc

SQL 2:

WITH RECURSIVE organization_children AS (
           SELECT entity.id, entity_relationship.parent_id, 1 as depth, entity_relationship.type, entity_relati

           FROM entity
           LEFT JOIN entity_relationship ON entity_relationship.child_id = entity.id
           WHERE entity.id = 194
          UNION
           SELECT next_child.id, entity_relationship.parent_id, depth + 1, entity_relationship.type, entity_rel

           FROM entity next_child
           JOIN entity_relationship ON entity_relationship.child_id = next_child.id
           JOIN organization_children c ON entity_relationship.parent_id = c.id
          )
            ,org_tree_id AS (
              SELECT id FROM (
              SELECT trees.id as id from trees
                WHERE
                  planter_id IN (
                    SELECT id FROM planter
                    JOIN (
                      SELECT id AS entity_id FROM organization_children LIMIT 20
                    ) org ON planter.organization_id = org.entity_id
                  )
              UNION
                select id from trees where planting_organization_id = (
                  194
                )
              ) ids

            )
select * from trees
where
(
  id in (select id from org_tree_id)
)
order by id desc
limit 2
offset 1000;

When this is done, we will use our test tool to do a pressure test against these two and check the result.

SamantaTarun commented 1 year ago

I'd like to work on it.

dadiorchen commented 1 year ago

@tarunsamanta2k20 hi, that's great, can you send me your email address so I can invite you to slack?

SamantaTarun commented 1 year ago

@tarunsamanta2k20 hi, that's great, can you send me your email address so I can invite you to slack?

tarunsamanta77@gmail.com

dadiorchen commented 1 year ago

@tarunsamanta2k20 I have messaged you on Slack, you are already in the community

dadiorchen commented 1 year ago

I have transfered this issue to our repo for the functions to deploy to openfaas