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

Change most used to most directly depended upon #111

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default Ember.Route.extend({
};
return ajax('/summary').then(function(data) {
addCrates(data.new_crates);
addCrates(data.most_downloaded);
addCrates(data.most_directly_depended_upon);
addCrates(data.just_updated);
return data;
});
Expand Down
6 changes: 3 additions & 3 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<h2>New Crates</h2>
{{render "crate-list" new_crates}}
</div>
<div id='most-downloaded'>
<h2>Most Downloaded</h2>
{{render "crate-list" most_downloaded}}
<div id='most-depended-upon'>
<h2>Most Depended Upon</h2>
{{render "crate-list" most_directly_depended_upon}}
</div>
<div id='just-updated'>
<h2>Just Updated</h2>
Expand Down
8 changes: 4 additions & 4 deletions src/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,22 +550,22 @@ pub fn summary(req: &mut Request) -> CargoResult<Response> {
WHERE updated_at::timestamp(0) !=
created_at::timestamp(0)
ORDER BY updated_at DESC LIMIT 10"));
let most_downloaded = try!(tx.prepare("SELECT * FROM crates \
ORDER BY downloads DESC LIMIT 10"));
let most_directly_depended_upon = try!(tx.prepare("SELECT * FROM crates \
ORDER BY dependencies-on DESC LIMIT 10"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see this column defined in the "schema" (as in, it's not mentioned in the migration code), am I missing something?

(If it turns out this isn't defined, one may wish to look at reverse_dependencies which does essentially exactly the same thing.)


#[derive(RustcEncodable)]
struct R {
num_downloads: i64,
num_crates: i64,
new_crates: Vec<EncodableCrate>,
most_downloaded: Vec<EncodableCrate>,
most_directly_depended_upon: Vec<EncodableCrate>,
just_updated: Vec<EncodableCrate>,
}
Ok(req.json(&R {
num_downloads: num_downloads,
num_crates: num_crates,
new_crates: try!(to_crates(new_crates)),
most_downloaded: try!(to_crates(most_downloaded)),
most_directly_depended_upon: try!(to_crates(most_directly_depended_upon)),
just_updated: try!(to_crates(just_updated)),
}))
}
Expand Down