Giveth / DeVouch-BE

DeVouch - Decentralized Vouching via Attestations
GNU General Public License v3.0
22 stars 2 forks source link

Default Sort response by count of attestation on projects #48

Closed divine-comedian closed 3 weeks ago

divine-comedian commented 1 month ago

The default sorting given by the unified API response of the projects should be projects that have the highest count of attestations (vouch AND Flags together) from all tracked attester groups.

If a filter has been applied to look only for a certain attester group then the default sorting should filter by this as well. Similarly if we filter for a specific platform.

divine-comedian commented 3 weeks ago

@aminlatifi - Did we already figure this one out?

aminlatifi commented 3 weeks ago

We can add define sort condition in queries like this

query {
  projects(orderBy:totalAttests_DESC, where: {
    attestedOrganisations_some:{
      organisation: {
        name_eq: "Trace"
      }
    }
  }) {
    title
    totalAttests
    totalVouches
    totalFlags
    attestedOrganisations {
      organisation {
        name
      }
      vouch
      count
    }
  }
}
divine-comedian commented 3 weeks ago

thanks! tested and response is as expected.

on first page load by user without any filtering or sorting applied by the user our default should be this:

{
  projects(orderBy: totalAttests_DESC) {
    title
    totalAttests
    totalVouches
    totalFlags
    attestedOrganisations {
      organisation {
        name
      }
      vouch
      count
    }
  }
}