AlexandriaDAO / core

https://xo3nl-yaaaa-aaaap-abl4q-cai.icp0.io/
MIT License
5 stars 3 forks source link

Advanced Queries & Clean ArWewave Metadata #35

Closed evanmcfarland closed 2 months ago

evanmcfarland commented 2 months ago

Goal: Change the Metadata of NFT uploads to a cleaner and permanent state that enables reasonable category filtering features.

Upload Requirements:

Query Requirements:

Basically, we need to be able to filter by categories in query.ts with OR statements instead of AND statements. We have types that we can filter by, and subtypes that we can filter by, but not both at the same time, otherwise they exclude each other.

Problems: Values are strings, so to have multiple types under the same name basically makes it useless to query by. Query package for Irys sucks, so raw graphql working in base form is commented out in query.ts. Which we might have to use.

Solution Proposal: I don’t know an ideal solution. Maybe just create a metadata field for all 10 Categories, and then filter with Javascript for Subcategories.

Each query would have to have 10 fields: type1, type2, type3, etc., and each would be a true/false or 0/1. We can simulate OR statements this way by setting each field in every query.

But again, this is not the ideal way because we can only filter 1 category at a time. If we do more than one than it will act as an exclusive AND statement. Note: A malicious actor can potentially spam attack us with fake book uploads to ArWeave with my same metadata. The base cost is $0.0025/transaction, so the filter system should be made with this possibility as a consideration. The implementation preferred for us is to add this line with the archive of NFT ids: .ids(legitimateTransactionIds) This should theoretically scale to the 10s of thousands before needing to add filtering.

evanmcfarland commented 2 months ago

Upon further attempts at making the GraphQL Setup I'm convinced that we can't effectively do OR statements to the API.

It's not going to be fun, but we're going to have to build a secondary database that tracks the NFTs and their metadata. This is going to be another issue.

The goal is that people will actually be able to find the books they're looking for, but getting exact matches on titles and authors will be very impractical. The query limit it also typically 100 results, so client-side adjustments is also impractical.

I will make simple AND queries for the main categories, and later we will need to build a secondary database @ search engine.

evanmcfarland commented 2 months ago

image

Done. Went with this basically