Skip to content

Commit

Permalink
Only count dependencies that matters!
Browse files Browse the repository at this point in the history
Fixes issue freebsd#225
  • Loading branch information
jlaffaye committed May 3, 2012
1 parent d0bdc65 commit 5d0b56a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libpkg/pkgdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,12 @@ pkgdb_query_installs(struct pkgdb *db, match_t match, int nbpkgs, char **pkgs, c
"(SELECT d.origin FROM '%s'.deps AS d, pkgjobs AS j WHERE d.package_id = j.pkgid) "
"AND (SELECT origin FROM main.packages WHERE origin=r.origin AND version=r.version) IS NULL;";

const char weight_sql[] = "UPDATE pkgjobs set weight=(select count(*) from '%s'.deps as d where d.origin=pkgjobs.origin)";
const char weight_sql[] = "UPDATE pkgjobs SET weight=("
"SELECT COUNT(*) FROM '%s'.deps AS d, '%s'.packages AS p, pkgjobs AS j "
"WHERE d.origin = pkgjobs.origin "
"AND d.package_id = p.id "
"AND p.origin = j.origin"
");";

assert(db != NULL);
assert(db->type == PKGDB_REMOTE);
Expand Down Expand Up @@ -2427,7 +2432,7 @@ pkgdb_query_installs(struct pkgdb *db, match_t match, int nbpkgs, char **pkgs, c
"FROM main.packages AS l, pkgjobs AS r WHERE l.origin = r.origin ");

sbuf_reset(sql);
sbuf_printf(sql, weight_sql, reponame);
sbuf_printf(sql, weight_sql, reponame, reponame);
sbuf_finish(sql);

sql_exec(db->sqlite, sbuf_get(sql));
Expand Down

0 comments on commit 5d0b56a

Please sign in to comment.