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

Add feature id filter #1108

Merged
merged 7 commits into from
May 11, 2024
Merged

Add feature id filter #1108

merged 7 commits into from
May 11, 2024

Conversation

CollinBeczak
Copy link
Contributor

@CollinBeczak CollinBeczak commented Mar 20, 2024

Feature request: A user requested the ability to filter with a feature Id.
This PR, and its corresponding frontend PR, adds support to filter by feature Id and updates the review CSV filtering to include the added feature Id filtering as well.

Endpoints this parameter is commonly used on:
PUT /tasks/box/:left/:bottom/:right/:top?fid=String
PUT /taskCluster?fid=String
GET /data/challenge/:id?fid=String
GET /tasks/review?fid=String
GET /tasks/review/reviewTable/export?fid=String

The filtering was implemented in this format: (LOWER(TRIM(tasks.name::TEXT)) LIKE LOWER('%example1%')), so it resolves conflicts related to capital letters and spacing.

Example of the query commonly used in filtering endpoints:

SELECT 
          tasks.*, tasks.geojson::TEXT AS geo_json, tasks.cooperative_work_json::TEXT AS cooperative_work, tasks.completion_responses::TEXT AS responses, ST_AsGeoJSON(tasks.location) AS geo_location , task_review.review_status, task_review.review_requested_by, task_review.reviewed_by, task_review.reviewed_at, task_review.review_started_at, task_review.meta_reviewed_by, task_review.meta_review_status, task_review.meta_reviewed_at, task_review.review_claimed_by, task_review.review_claimed_at, task_review.additional_reviewers, task_review.error_tags  FROM tasks
          INNER JOIN challenges c ON c.id = tasks.parent_id
          INNER JOIN task_review ON task_review.task_id = tasks.id
          INNER JOIN projects p ON p.id = c.parent_id
        WHERE (LOWER(TRIM(tasks.name::TEXT)) LIKE LOWER('%node/-168461%')) AND (task_review.review_requested_by IS NOT NULL) AND (c.id IN (32)) AND (task_review.review_status <> 5) AND ((tasks.bundle_id IS NULL OR tasks.is_bundle_primary)) ORDER BY mapped_on ASC LIMIT 20 OFFSET 0;

Example of the query commonly used in export review table query:

 SELECT
              -- tasks fields
              tasks.id,
              tasks.name,
              tasks.created,
              tasks.modified,
              tasks.parent_id,
              tasks.instruction,
              ST_AsGeoJSON(tasks.location) AS geo_location,
              tasks.status,
              tasks.geojson::TEXT AS geo_json,
              tasks.cooperative_work_json::TEXT AS cooperative_work,
              tasks.mapped_on,
              tasks.completed_time_spent,
              tasks.completed_by,
              tasks.priority,
              tasks.changeset_id,
              tasks.bundle_id,
              tasks.is_bundle_primary,
              tasks.completion_responses::TEXT AS responses,

              -- task_review fields
              task_review.review_status,
              task_review.review_requested_by,
              task_review.reviewed_by,
              task_review.reviewed_at,
              task_review.meta_reviewed_by,
              task_review.meta_review_status,
              task_review.meta_reviewed_at,
              task_review.review_started_at,
              task_review.review_claimed_by,
              task_review.review_claimed_at,
              task_review.additional_reviewers,
              task_review.error_tags,

              -- challenges and projects fields
              c.name AS challenge_name,
              p.id AS project_id,
              p.display_name AS project_name,

              -- users fields
              mappers.name AS review_requested_by_username,
              reviewers.name AS reviewed_by_username

            FROM tasks
            -- Joining with task_review
            INNER JOIN task_review ON task_review.task_id = tasks.id

            -- Joining with challenges and projects
            INNER JOIN challenges c ON c.id = tasks.parent_id
            INNER JOIN projects p ON p.id = c.parent_id

            -- Joining with users
            LEFT OUTER JOIN users mappers ON task_review.review_requested_by = mappers.id
            LEFT OUTER JOIN users reviewers ON task_review.reviewed_by = reviewers.id
       WHERE (LOWER(TRIM(tasks.name::TEXT)) LIKE LOWER('%node/-168461%')) AND (tasks.priority IN (0,1,2)) AND (task_review.review_requested_by IS NOT NULL) AND ((task_review.meta_review_status IN (-2,0,1,2,3,6) OR task_review.meta_review_status IS NULL)) AND (tasks.status IN (0,1,2,3,4,5,6,9)) AND (c.id IN (32)) AND (task_review.review_status IN (0,1,2,3,4,5,6,7,-1)) AND (task_review.review_status <> 5) AND ((tasks.bundle_id IS NULL OR tasks.is_bundle_primary)) ORDER BY mapped_on ASC;

Copy link

sonarqubecloud bot commented Apr 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@CollinBeczak CollinBeczak marked this pull request as ready for review April 9, 2024 18:47
@ljdelight ljdelight self-requested a review May 11, 2024 23:01
Copy link
Contributor

@ljdelight ljdelight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CollinBeczak CollinBeczak merged commit 72645d4 into main May 11, 2024
7 checks passed
@CollinBeczak CollinBeczak deleted the add-feature-id-filter branch May 11, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants