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

cas -541: update search endpoint #546

Closed
wants to merge 24 commits into from
Closed

Conversation

0xmovses
Copy link
Contributor

@0xmovses 0xmovses commented Sep 28, 2022

•adds method appendFiltersToResponse
•adds necessary fields onto search response
•extends SQL query
•adds constructDynamicSQL method for dynamic filter params
•moves community models sql queries into constants
•creates new generalised model function GetDefaultCommunities for both homepage SQL and default search SQL ( this felt like the right thing to do as they use similar SQL queries)

*Know Issue
if the search query contains a space, and its url encoded with a % I get a 400 back. This seems to be something to do with mux https://github.com/gorilla/mux/issues/77 I have tried the various fixes on the repo but so far none of the solutions working

@linear
Copy link

linear bot commented Sep 28, 2022

CAS-541

@0xmovses 0xmovses changed the title cas -541: update search endpoint WIP cas -541: update search endpoint Sep 30, 2022
@germanurrus
Copy link
Contributor

germanurrus commented Oct 3, 2022

It looks like the default search is not filtering correctly:

The URL is:
http://localhost:5001/communities/search/defaultFeatured?start=0&count=10
The expected defaultFeatured should make filters to return only filters for the feature ones, also the all filter is gone.
I only have one feature community then dao should be 1 and the all filter should exist with one
Also when sending a filter that has 0 the result is the same, and the response brings the one feature community.
(Note: I've added a category to the Flow community manually and it's dao and also I have created a second community using dao)

{
    "filters": [
        {
            "text": "dao",
            "amount": 2
        },
        {
            "text": "social",
            "amount": 0
        },
        {
            "text": "protocol",
            "amount": 0
        },
        {
            "text": "creator",
            "amount": 0
        },
        {
            "text": "nft",
            "amount": 0
        },
        {
            "text": "collector",
            "amount": 0
        }
    ],
    "results": {
        "data": [
            {
                "id": 1,
                "name": "Flow",
                "category": "dao",
                "categoryCount": 2,
                "body": "Vote on Flow Validators",
                "timestamp": "",
                "compositeSignatures": null,
                "creatorAddr": ""
            }
        ],
        "start": 0,
        "count": 1,
        "totalRecords": 1,
        "next": -1
    }
}

@germanurrus
Copy link
Contributor

also when sending text with space the front gets a 404:
Screen Shot 2022-10-03 at 01 22 21

@0xmovses
Copy link
Contributor Author

0xmovses commented Oct 3, 2022

The all field has been added

I've adjusted the SQL;
now when I do
http://localhost:5001/communities/search/defaultFeatured?start=0&count=10

I get :

{
    "filters": [
        {
            "text": "dao",
            "amount": 0
        },
        {
            "text": "social",
            "amount": 0
        },
        {
            "text": "protocol",
            "amount": 0
        },
        {
            "text": "creator",
            "amount": 1
        },
        {
            "text": "nft",
            "amount": 0
        },
        {
            "text": "collector",
            "amount": 0
        },
       {
            "text": "all",
            "amount":  1
        }
    ],
    "results": {
        "data": [
            {
                "id": 114,
                "name": "rich",
                "category": "creator",
                "categoryCount": 1,
                "body": "<html>something</html>",
                "timestamp": "",
                "compositeSignatures": null,
                "creatorAddr": ""
            }
        ],
        "start": 0,
        "count": 1,
        "totalRecords": 1,
        "next": -1
    }
}

URL encoded Special characters I am blocked on due to known issue with mux library. I've tried various solutions suggested on their issues page but none have worked so for.

@germanurrus
Copy link
Contributor

The all field has been added

I've adjusted the SQL; now when I do http://localhost:5001/communities/search/defaultFeatured?start=0&count=10

I get :

{
    "filters": [
        {
            "text": "dao",
            "amount": 0
        },
        {
            "text": "social",
            "amount": 0
        },
        {
            "text": "protocol",
            "amount": 0
        },
        {
            "text": "creator",
            "amount": 1
        },
        {
            "text": "nft",
            "amount": 0
        },
        {
            "text": "collector",
            "amount": 0
        },
       {
            "text": "all",
            "amount":  1
        }
    ],
    "results": {
        "data": [
            {
                "id": 114,
                "name": "rich",
                "category": "creator",
                "categoryCount": 1,
                "body": "<html>something</html>",
                "timestamp": "",
                "compositeSignatures": null,
                "creatorAddr": ""
            }
        ],
        "start": 0,
        "count": 1,
        "totalRecords": 1,
        "next": -1
    }
}

URL encoded Special characters I am blocked on due to known issue with mux library. I've tried various solutions suggested on their issues page but none have worked so for.

For some reason this is not working on my side, I still get the same filters are before.

Just for clarification, then the defaultFeatured is sent as query search param, the frontend is expecting filters to be populated with the amount calculated based the featured communities returned.
When a text search is entered, filters should adjust on the result based on the search test.

The All filter is always present, with the total amount of communities returned based on the search text or the defaultFeatured.
When a filter is pressed, results changes but filters are the same and are kept based on the search text

@0xmovses
Copy link
Contributor Author

0xmovses commented Oct 3, 2022

I just pushed again and I think there was one change not pushed to the branch; could you try pulling again?

I just tested again and it seems to be working as expected with all filter always present, no duplicate dao filter counts etc. defaultFeatured only returns communities with is_featured column set to true.

I just did http://localhost:5001/communities/search/defaultFeatured?start=0&count=10

and get returned

{
    "filters": [
        {
            "text": "dao",
            "amount": 0
        },
        {
            "text": "social",
            "amount": 0
        },
        {
            "text": "protocol",
            "amount": 0
        },
        {
            "text": "creator",
            "amount": 2
        },
        {
            "text": "nft",
            "amount": 0
        },
        {
            "text": "collector",
            "amount": 0
        },
        {
            "text": "all",
            "amount": 2
        }
    ],
    "results": {
        "data": [
            {
                "id": 114,
                "name": "rich",
                "category": "creator",
                "categoryCount": 2,
                "body": "<html>something</html>",
                "timestamp": "",
                "compositeSignatures": null,
                "creatorAddr": ""
            },
            {
                "id": 115,
                "name": "rich",
                "category": "creator",
                "categoryCount": 2,
                "body": "<html>something</html>",
                "timestamp": "",
                "compositeSignatures": null,
                "creatorAddr": ""
            }
        ],
        "start": 0,
        "count": 2,
        "totalRecords": 2,
        "next": -1
    }
}

@dbslone dbslone requested review from jbluks and germanurrus October 3, 2022 21:20
@germanurrus
Copy link
Contributor

  • Filters for featured communities are not working, and filtering returns the same result for feature communities:

Screen Shot 2022-10-03 at 19 05 17

In the image above, there should not be any results since I'm selecting a pill with no results (maybe if the pill is 0 make it not clickable) but still the backend should return 0 results
  • When entering text with spaces, the url is not found and we get a 404 as a response:

Screen Shot 2022-10-03 at 01 22 21

  • Filters are not working on when results are returned on search, in the example below we should see only one result:

Screen Shot 2022-10-03 at 19 23 53

Copy link
Contributor

@germanurrus germanurrus left a comment

Choose a reason for hiding this comment

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

Make comments about three bugs found on filtering. It's possible to test using the frontend PR #542

@jbluks
Copy link
Collaborator

jbluks commented Oct 5, 2022

This PR will now be handled by this: #574

@jbluks jbluks closed this Oct 5, 2022
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.

3 participants