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

when filtering for specific attester organization sort most vouches by filtered orgs #118

Open
4 tasks
divine-comedian opened this issue Sep 24, 2024 · 21 comments
Assignees

Comments

@divine-comedian
Copy link
Contributor

divine-comedian commented Sep 24, 2024

when we are sorting and filtering by an attester org we should sort by most vouches for the org that is being filtered for, same if we are filtering for multiple orgs we should use the most vouches across the total of the orgs being filtered for.

@MohammadPCh needs to provide query snipper for @mateodaza to use in the front-end

FOR EXAMPLE

FILTER FOR SINGLE ORG
consider this view, we filtered project by if they have received attestations from RF 5 or 6 voters..
currently the projects with the most total vouches from all orgs are shown on top.

The top project shown has 2 vouches from RF 5 or 6 voters, while some projects further below have 3 or more vouches from this group. We should show instead the projects that have the most vouches from the specified filtered org FIRST then descending downwards.
image

FILTER FOR MULTIPLE ORGS
In addition if we filtered for multiple orgs, such as RF 5/6 voters AND Giveth Verifiers we should consider the sum of vouches/flags (depending on the sort chosen) to decide the ordering of projects.

Consider this

Gitcoin Passport Holders Giveth Verifiers RF5/6 Voters Total eligible Vouches Ordering in List view
Project A 22 4 2 6 3
Project B 5 2 3 5 4
Project C 1 6 1 7 2
Project D 15 3 5 8 1

Since we are filtering for RF 5/6 Voters and Giveth Verifiers we don't consider the Gitcoin Passport Holders when ordering the projects in the list. According to the example above the projects should be down in order from highest to lowest as:

  1. D
  2. C
  3. B
  4. A

AC

  • when filtering by one attester org, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches from the specified attester org that's been filtered for
  • when filtering by multiple attester orgs, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches TOTAL from the specified attester orgs that's been filtered for
  • when no filter is applied projects are shown highest to lowest from the sum of ALL attester orgs
  • when a filter is applied for single or multiple orgs AND source platform the aforementioned sorting is applied AND only shows projects from specified source platforms.
@divine-comedian divine-comedian moved this to Todo in DeVouch Sep 24, 2024
@MohammadPCh MohammadPCh moved this from Todo to In progress in DeVouch Oct 3, 2024
@divine-comedian
Copy link
Contributor Author

Cherik is implementing for 1 organization, maybe he can fix it for multiple organizations, needs more investigation

@MohammadPCh
Copy link
Collaborator

@mateodaza @divine-comedian The BE is ready for it:
you can test it here:
https://backend.devouch.xyz/graphql
this is the query:

query MyQuery($limit: Float = 10, $offset: Float = 0, $orgIds: [String!] = "", $sortBy: String = "") {
  getProjectsSortedByVouchOrFlag(orgIds: $orgIds, sortBy: $sortBy, limit: $limit, offset: $offset) {
    id
  }
}

and these are the variables:

{
  "offset": 0,
  "limit": 100,
  "sortBy": "totalVouches_DESC",
  "orgIds": ["0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"]
}

unfortunately, we only return the projects' Ids here and you have to send another request to fetch the projects' data with attestations and organization.

let me know if you have any question.

@MohammadPCh MohammadPCh moved this from In progress to Code Review in DeVouch Oct 15, 2024
@MohammadPCh MohammadPCh moved this from Code Review to QA in DeVouch Oct 15, 2024
@mateodaza
Copy link
Member

mateodaza commented Oct 25, 2024

@MohammadPCh this worked perfectly, thanks for that - I'm leaving a draft PR here while I solve a question I got while integrating...

Can we add also a way to filter by sources like the regular query? I believe this is needed to keep previous functionality untouched

cc @divine-comedian

PS: also not sure if worth giving a try but, maaybe we can bring all the projects as well instead of only the id by doing a connection type of query, maybe it'd help to keep it lighter and not do double requests on the frontend

@MohammadPCh
Copy link
Collaborator

@mateodaza Thanks! You’re absolutely right; we needed to handle the source in the query. Here’s the updated version:

query MyQuery($sortBy: String, $sources: [String!], $organizations: [String!], $limit: Int, $offset: Int) {
  getProjectsSortedByVouchOrFlag(limit: $limit, offset: $offset, organizations: $organizations, sortBy: $sortBy, sources: $sources) {
    id
  }
}
{
  "limit": 10,
  "offset": 0,
  "sortBy": "totalVouches_DESC",
  "sources": ["giveth"],
  "organizations": ["0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"]
}

As for using connections, I gave it a try, but it’s challenging to integrate with Subsquid—or maybe I’m not fully sure how to handle it yet. Let’s stick with this approach for now, and we can look into improving it in the future.

@divine-comedian
Copy link
Contributor Author

@mateodaza Thanks! You’re absolutely right; we needed to handle the source in the query. Here’s the updated version:

query MyQuery($sortBy: String, $sources: [String!], $organizations: [String!], $limit: Int, $offset: Int) {
  getProjectsSortedByVouchOrFlag(limit: $limit, offset: $offset, organizations: $organizations, sortBy: $sortBy, sources: $sources) {
    id
  }
}
{
  "limit": 10,
  "offset": 0,
  "sortBy": "totalVouches_DESC",
  "sources": ["giveth"],
  "organizations": ["0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"]
}

As for using connections, I gave it a try, but it’s challenging to integrate with Subsquid—or maybe I’m not fully sure how to handle it yet. Let’s stick with this approach for now, and we can look into improving it in the future.

maybe @aminlatifi or @jainkrati can help you if you need some technical expertise

Also there is the subsquid documentation, is this article relevant?
https://docs.sqd.dev/sdk/reference/schema-file/entity-relations/

@divine-comedian
Copy link
Contributor Author

@LatifatAbdullahi I've added in additional context and AC to help you with QA - it should be ready for you to test.

@LatifatAbdullahi
Copy link

LatifatAbdullahi commented Nov 7, 2024

@MohammadPCh @mateodaza

Test Update

  • When filtering by one attester org, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches from the specified attester org that's been filtered for - Pass
  • When filtering by multiple attester orgs, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches TOTAL from the specified attester orgs that's been filtered for - Pass
  • When no filter is applied projects are shown highest to lowest from the sum of ALL attester orgs - Pass
  • When a filter is applied for single or multiple orgs AND source platform the aforementioned sorting is applied AND only shows projects from specified source platforms - Failed

Filtering from specified source platforms with single or multiple Orgs still fetches Projects from other sources if its attested by the selected Orgs.

For example, I filtered by RF Round 5 and Honorary Mexican, expecting Only Projects from the source platforms(RF Round 5) with attestations form Honorary Mexican(with other attestations if available), but I can see Projects from another unselected Source platform(Giveth) because it also has attestations from (Honorary mexican)

ik

@LatifatAbdullahi LatifatAbdullahi moved this from QA to In progress in DeVouch Nov 7, 2024
@mateodaza
Copy link
Member

Tagging @MohammadPCh
I think this is backend related 🫠

@MohammadPCh
Copy link
Collaborator

@LatifatAbdullahi @mateodaza Thanks Guys.
@mateodaza Here's the JSON payload that the front end sends when a user applies these filters:

{
  "organizations": [
    "0xc80d5c0209976a6c994aa6dc3680f4ad2de2dbc1aa9f46164c251ad9e5e10e09"
  ],
  "sortBy": "totalVouches_DESC",
  "limit": 20,
  "offset": 0
}

so as you can see there is no source field in this data.

@mateodaza
Copy link
Member

mateodaza commented Nov 11, 2024

@MohammadPCh sorry for not been so clear, the issue is that getProjectsSortedByVouchOrFlag doesn't support rfRounds

I can send rf by itself but it won't filter by specific round

For now I'll just leave it working so it shows any round if a voucher is selected in the filter
@LatifatAbdullahi this is ready to test

@MohammadPCh
Copy link
Collaborator

@mateodaza Thanks for clarifying!

I fixed this issue on staging a few days ago, so you should be able to send rfround (an array of numbers) now. Let me know if you run into any issues with it.

@mateodaza
Copy link
Member

nice yes! thanks a lot @MohammadPCh

@mateodaza
Copy link
Member

@MohammadPCh although I found a bug

It excludes non rf sources if I send that array, can you double check that query?

@divine-comedian
Copy link
Contributor Author

testing this out it on staging it seems when I filter by specific RF round and for specific attester org the returned results are from ALL RF rounds, it does not correctly filter for the specific RF round, however it does correctly filter for non RF source platforms (only Giveth or only Gitcoin) with a specified attester org

VideoCompressorResizeCompressVideo2024_11_13_09_33_51.mp4

Is there something else I'm missing? Looks like it's changed a bit from the testing @LatifatAbdullahi did earlier

@LatifatAbdullahi
Copy link

LatifatAbdullahi commented Nov 13, 2024

@divine-comedian Yes, something seems to have broken, @mateodaza confirmed yesterday that its still being worked and will let me know when to retest.

@MohammadPCh
Copy link
Collaborator

@divine-comedian @LatifatAbdullahi, the API is working fine. I'll add the source and rfRounds fields to the returning fields so you can test it more easily.

@LatifatAbdullahi
Copy link

@MohammadPCh Thanks, please let me know when its ready to be retested, as it seems it still doesnt filter correctly for specific RF rounds

il

@LatifatAbdullahi
Copy link

Test Update

  • When filtering by one attester org, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches from the specified attester org that's been filtered for - Pass
  • When filtering by multiple attester orgs, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches TOTAL from the specified attester orgs that's been filtered for - Pass
  • When no filter is applied projects are shown highest to lowest from the sum of ALL attester orgs - Pass

@MohammadPCh @mateodaza

  • When a filter is applied for single or multiple orgs AND source platform the aforementioned sorting is applied AND only shows projects from specified source platforms. - Failed

Filtering specific single/multiple Source platforms still returns data from other source platforms, this bug still applies to only RF Source platform, filtering for single or multiple RF Projects still returns data from other unselected RF source projects as because the unselected RF project contains the selected Attester Org.

DeVouch._.Decentralized.Vouching.for.the.Projects.you.Trust.-.Google.Chrome.2024-11-18.10-34-55.mp4

tuu

@MohammadPCh
Copy link
Collaborator

MohammadPCh commented Nov 18, 2024

@LatifatAbdullahi Thanks for reporting this problem
I really appreciate it if you could test this issue here:
https://backend.devouch.xyz/graphql
so we can make sure the problem is BE side.
for this test you can test it by this query:

query MyQuery($limit: Int = 10, $offset: Int = 10, $organizations: [String!] = "", $rfRounds: [Int!] = 10, $sortBy: String = "", $sources: [String!] = "") {
  getProjectsSortedByVouchOrFlag(limit: $limit, offset: $offset, rfRounds: $rfRounds, sortBy: $sortBy, sources: $sources, organizations: $organizations) {
    id
    rfRounds
    source
  }
}

and this is the variables:

{
  "organizations": [
    "0x9224f06bd11d0076dbcb28e4f0c654d78cb071930653510360a3a00518ad1710","0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"
  ],
  "sources": ["rf"],
  "rfRounds": [5],
  "sortBy": "totalVouches_DESC",
  "limit": 20,
  "offset": 0
}

@LatifatAbdullahi
Copy link

@MohammadPCh @mateodaza

First example:

Using the https://backend.devouch.xyz/graphql ; seems to return the expected results alone

eke

Filtering with same data on Staging FE; seems to return extra wrong results

rw

Second example:

Using the https://backend.devouch.xyz/graphql ; seems to return the expected results alone

eb

Filtering with same data on Staging FE; seems to return extra wrong results

en

Filtering on the BE https://backend.devouch.xyz/graphql seems to be returning the right data unlike the staging FE

@LatifatAbdullahi
Copy link

Test Update

Thanks @mateodaza @MohammadPCh

@divine-comedian The issue is now fixed

  • When filtering by one attester org, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches from the specified attester org that's been filtered for - Pass
  • When filtering by multiple attester orgs, with sort of most vouches applied, list of projects show from highest to lowest the projects that have received the MOST vouches TOTAL from the specified attester orgs that's been filtered for - Pass
  • When no filter is applied projects are shown highest to lowest from the sum of ALL attester orgs - Pass
  • When a filter is applied for single or multiple orgs AND source platform the aforementioned sorting is applied AND only shows projects from specified source platforms - Pass

image

@LatifatAbdullahi LatifatAbdullahi moved this from In progress to Done in DeVouch Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants