Greenstand / treetracker-admin-api

Legacy API microservice for the admin panel
GNU Affero General Public License v3.0
31 stars 80 forks source link

feat: add join clause for trees with any tagid #608

Closed bstetzer32 closed 2 years ago

bstetzer32 commented 2 years ago

Description

Added condition to getTreeTagJoinClause for an INNER JOIN on trees and tree_tag when tagId is 0, so that trees can be filtered by all trees with a tag.

Issue(s) addressed

What kind of change(s) does this PR introduce?

Please check if the PR fulfills these requirements

Issue

What is the current behavior? If the tagId is null getTreeTagJoinClause currently returns all trees that do not have a tree_tag record (SELECT ... from trees LEFT JOIN tree_tag ON trees.id=tree_tag.tree_id WHERE (tree_tag.tag_id ISNULL)), otherwise it returns a query for all trees with the tagId specified(SELECT ... from trees JOIN tree_tag ON trees.id=tree_tag.tree_id WHERE (tree_tag.tag_id=${tagId})).

What is the new behavior? Added a condition so that if tagId is "0" (string), then it will return all trees that have a tree tag record (SELECT ... from trees INNER JOIN tree_tag ON trees.id=tree_tag.tree_id).

Breaking change

Does this PR introduce a breaking change? No breaking changes.

Other useful information