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

Collections, pagination, sorting #17

Closed
joepio opened this issue Sep 23, 2020 · 3 comments
Closed

Collections, pagination, sorting #17

joepio opened this issue Sep 23, 2020 · 3 comments

Comments

@joepio
Copy link
Member

joepio commented Sep 23, 2020

Collections are (dynamic) lists of items that add pagination and sorting.

A few things that I'd want to be able to do:

  • Visit https://atomicdata.dev/classes and see all the classes
  • Visit https://atomicdata.dev/collections and see a list of all collections
  • Create these collections using something as atomic-cli new collection - not requiring any programming
  • be able to browse large collections using pagination
joepio added a commit that referenced this issue Sep 23, 2020
@joepio
Copy link
Member Author

joepio commented Oct 28, 2020

I've implemented a basic collection model:

pub struct Collection {
  // The set of triples that form the basis of the data
  pub tpf: TPFQuery,
  // List of all the pages.
  pub pages: Vec<Page>,
  // URL of the value to sort by
  pub sort_by: String,
  // Sorts ascending by default
  pub sort_desc: bool,
  // How many items per page
  pub page_size: u8,
  // Current page number, defaults to 0 (first page)
  pub current_page: u8,
  // Total number of items
  pub total_items: u8,
  // Total number of pages
  pub total_pages: u8,
}

However, one question still remains: how does a user access a collection? A Collection uses query params (which isn't standardized in Atomic Data yet) to browser pages, or do sorting.

I'd like to implement Collections in Atomic-Lib without having any special handlers or views in Atomic-Server. This seems like the most elegant way of handling with this functionality.

So let's assume a request comes in for some collection resource, sorted by date: https://example.com/classes?sortBy=date. The Store's get_resource function parses the path, notices the Query Param and is able to do something with it... How does the store know how to deal with this specific type of query param and resource? It will need some type of handler. Perhaps it checks the type of the resource and matches it to some handledClasses list, which maps to some functions. Doing this will make the get_resource function (way) slower, so perhaps we need some other function (get_resource_extended) that is called by server, instead.

joepio added a commit that referenced this issue Oct 28, 2020
joepio added a commit that referenced this issue Oct 28, 2020
@joepio
Copy link
Member Author

joepio commented Oct 29, 2020

Made some progress on collections. Basics are working, but I still need to:

  • create tests
  • implement some query param parsers.
  • Sorting
  • Pagination

joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
@joepio
Copy link
Member Author

joepio commented Oct 30, 2020

I'll probably pick up sorting sometime later, but for now I'm happy with where I'm at. Closing this.

@joepio joepio closed this as completed Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
joepio added a commit that referenced this issue Oct 30, 2020
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

No branches or pull requests

1 participant