Skip to content

Commit d04c68d

Browse files
committed
Handle watchers and fork for suites. Fixes jquery-archive#20.
1 parent 67eab6a commit d04c68d

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

src/hook.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function processRelease( repo, tag, file, package, fn ) {
123123
// find out who owns this plugin
124124
// if there is no owner, then set the user as the owner
125125
function() {
126-
pluginsDb.getOrSetOwner( package.name, repo.userId, this );
126+
pluginsDb.getOrSetOwner( package.name, repo.userId, repo.id, this );
127127
},
128128

129129
// verify the user is the owner
@@ -164,20 +164,7 @@ function processRelease( repo, tag, file, package, fn ) {
164164
function processMeta( repo, fn ) {
165165
Step(
166166
function() {
167-
repo.getPackageJson( null, this );
168-
},
169-
170-
function( error, package ) {
171-
if ( error ) {
172-
retry.log( "processMeta", repo.id );
173-
return fn( error );
174-
}
175-
176-
if ( !package || !package.name ) {
177-
return fn( null );
178-
}
179-
180-
pluginsDb.updatePlugin( package.name, repo.userId, {
167+
pluginsDb.updateRepoMeta( repo.id, {
181168
watchers: repo.watchers,
182169
forks: repo.forks
183170
}, this );

src/pluginsdb.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ var pluginsDb = module.exports = {
4242
});
4343
}),
4444

45-
setOwner: auto(function( plugin, owner, fn ) {
46-
db.run( "INSERT INTO plugins( plugin, owner ) VALUES( ?, ? )",
47-
[ plugin, owner ], function( error ) {
45+
setOwner: auto(function( plugin, owner, repo, fn ) {
46+
db.run( "INSERT INTO plugins( plugin, owner, repo ) VALUES( ?, ?, ? )",
47+
[ plugin, owner, repo ], function( error ) {
4848
if ( error ) {
4949
return fn( error );
5050
}
@@ -53,8 +53,8 @@ var pluginsDb = module.exports = {
5353
});
5454
}),
5555

56-
getOrSetOwner: auto(function( plugin, owner, fn ) {
57-
pluginsDb.setOwner( plugin, owner, function( error ) {
56+
getOrSetOwner: auto(function( plugin, owner, repo, fn ) {
57+
pluginsDb.setOwner( plugin, owner, repo, function( error ) {
5858
// successfully set owner (new plugin)
5959
if ( !error ) {
6060
return fn( null, owner );
@@ -105,10 +105,10 @@ var pluginsDb = module.exports = {
105105
});
106106
}),
107107

108-
updatePlugin: auto(function( plugin, owner, data, fn ) {
108+
updateRepoMeta: auto(function( repo, data, fn ) {
109109
db.run( "UPDATE plugins SET watchers = ?, forks = ? " +
110-
"WHERE plugin = ? AND owner = ?",
111-
[ data.watchers, data.forks, plugin, owner ], fn );
110+
"WHERE repo = ?",
111+
[ data.watchers, data.forks, repo ], fn );
112112
}),
113113

114114
getMeta: auto(function( plugin, fn ) {
@@ -161,6 +161,7 @@ var pluginsDb = module.exports = {
161161
db.run( "CREATE TABLE plugins (" +
162162
"plugin TEXT PRIMARY KEY, " +
163163
"owner TEXT, " +
164+
"repo TEXT, " +
164165
"watchers INTEGER DEFAULT 0, " +
165166
"forks INTEGER DEFAULT 0" +
166167
")", this.parallel() );

0 commit comments

Comments
 (0)