Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose all download history through the API #557
Comments
This comment has been minimized.
This comment has been minimized.
|
Right now the only route for this is the downloads route but that just provides the data you see rendered already. I don't believe there's a route for a historical paginated version of this. Adding one would be fine though! |
This comment has been minimized.
This comment has been minimized.
|
Thank you for that link! I will try and grok the code and open a pr. So far I mostly have questions. :-P I think the comment may be out of date or I don't know how to read it, the link /crates/quadrature/downloads just gets me an error. It seems to be maching L89: "/crates/:crate_id/:version" insted of line L94: "/crates/:crate_id/downloads". Is there some kind of caching for Is there some kind of caching for the website? All the download counts (except for today's data) are going to be static, seems a shame to hit the database repeatedly. Is there a schema for the tables that we can query? |
This comment has been minimized.
This comment has been minimized.
|
Nah currently we don't have any caching, everything hits the database. Also there's currently no caching around |
This comment has been minimized.
This comment has been minimized.
|
I will experiment with a locale instance when I have a chance. :-) How do I hit the "/crates/:crate_id/:version" target? Everything I try just gets me error messages. |
This comment has been minimized.
This comment has been minimized.
|
This should do the trick:
|
carols10cents
changed the title
programmatically got downlod history?
Expose all download history through the API
Feb 21, 2017
carols10cents
added
A-API
C-enhancement
labels
Feb 21, 2017
This comment has been minimized.
This comment has been minimized.
|
Concrete suggestion: let offset = req.query().get("offset").parce().unwrap_or(0);
let cutoff_date_end = ::now() + Duration::days(-offset);
let cutoff_date_start = cutoff_date_end + Duration::days(-90);This is primarily the smallest change I can think of to make the data available. |
This comment has been minimized.
This comment has been minimized.
|
Alternative suggestion: let offset = req.query().get("page").parce().unwrap_or(0);
let cutoff_date_end = ::now() + Duration::days(-90 * offset);
let cutoff_date_start = cutoff_date_end + Duration::days(-90);Are these at all an acceptable idea? How can these ideas be improved? |
This comment has been minimized.
This comment has been minimized.
|
Sure, paging sounds great and would match other endpoints' interfaces. |
This comment has been minimized.
This comment has been minimized.
|
Random note if that endpoint is using Diesel by the time someone gets to it -- it can be done entirely in SQL as use diesel::expression::dsl::*;
let cutoff_end_date = now - (90 * offset).days();
let cuttof_start_date = cutoff_end_date - 90.days(); |
This comment has been minimized.
This comment has been minimized.
All of the endpoints moved to Diesel do! ;) https://github.com/diesel-rs/diesel/blob/428db9515e5c7769a9313b4cf9bc14f1ced290e7/diesel/src/connection/statement_cache.rs |
This comment has been minimized.
This comment has been minimized.
|
Closed in #611 |
Eh2406 commentedFeb 15, 2017
Hi,
What is the best way to get the download history for all crates? The data is publicly available by scraping the graphs out of each crates page, but that is rude and inelegant.
If the data is available, how can I improve the docs to make it easier to find?
If it is not available, what can I do to add that functionality?