Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build two openfaas function to test these two SQL #1

Open
dadiorchen opened this issue Jun 22, 2023 · 5 comments
Open

Build two openfaas function to test these two SQL #1

dadiorchen opened this issue Jun 22, 2023 · 5 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@dadiorchen
Copy link
Contributor

dadiorchen commented Jun 22, 2023

We aready setup our openfaas by Greenstand/treetracker-infrastructure#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.

@dadiorchen dadiorchen added the good first issue Good for newcomers label Jun 22, 2023
@SamantaTarun
Copy link
Member

I'd like to work on it.

@dadiorchen
Copy link
Contributor Author

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

@SamantaTarun
Copy link
Member

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

[email protected]

@dadiorchen
Copy link
Contributor Author

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

@dadiorchen dadiorchen transferred this issue from Greenstand/treetracker-infrastructure Jun 24, 2023
@dadiorchen
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants