Fix broken scraping and indexing
This commit is contained in:
parent
508b35f6d1
commit
f27d748246
2 changed files with 12 additions and 10 deletions
|
@ -545,25 +545,26 @@ Scholar.Item.prototype.save = function(){
|
|||
|
||||
sql = "SELECT COUNT(*) FROM itemData WHERE itemID=? AND fieldID=?";
|
||||
var countStatement = Scholar.DB.getStatement(sql);
|
||||
countStatement.bindInt32Parameter(0, this.getID());
|
||||
|
||||
sql = "UPDATE itemData SET value=? WHERE itemID=? AND fieldID=?";
|
||||
var updateStatement = Scholar.DB.getStatement(sql);
|
||||
updateStatement.bindInt32Parameter(1, this.getID());
|
||||
|
||||
sql = "INSERT INTO itemData VALUES (?,?,?)";
|
||||
var insertStatement = Scholar.DB.getStatement(sql);
|
||||
insertStatement.bindInt32Parameter(0, this.getID());
|
||||
|
||||
for (fieldID in this._changedItemData.items){
|
||||
if (this.getField(fieldID)){
|
||||
// Oh, for an INSERT...ON DUPLICATE KEY UPDATE
|
||||
countStatement.bindInt32Parameter(0, this.getID());
|
||||
countStatement.bindInt32Parameter(1, fieldID);
|
||||
countStatement.executeStep();
|
||||
var exists = countStatement.getInt64(0);
|
||||
countStatement.reset();
|
||||
|
||||
// Update
|
||||
if (exists){
|
||||
updateStatement.bindInt32Parameter(1, this.getID());
|
||||
|
||||
Scholar.History.modify('itemData', 'itemID-fieldID',
|
||||
[this.getID(), fieldID]);
|
||||
|
||||
|
@ -587,7 +588,7 @@ Scholar.Item.prototype.save = function(){
|
|||
this.getField(fieldID));
|
||||
}
|
||||
updateStatement.bindInt32Parameter(2, fieldID);
|
||||
updateStatement.executeStep();
|
||||
updateStatement.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,6 +597,7 @@ Scholar.Item.prototype.save = function(){
|
|||
Scholar.History.add('itemData', 'itemID-fieldID',
|
||||
[this.getID(), fieldID]);
|
||||
|
||||
insertStatement.bindInt32Parameter(0, this.getID());
|
||||
insertStatement.bindInt32Parameter(1, fieldID);
|
||||
|
||||
if (Scholar.ItemFields.getID('accessDate')==fieldID
|
||||
|
@ -617,7 +619,7 @@ Scholar.Item.prototype.save = function(){
|
|||
this.getField(fieldID));
|
||||
}
|
||||
|
||||
insertStatement.executeStep();
|
||||
insertStatement.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -714,13 +716,13 @@ Scholar.Item.prototype.save = function(){
|
|||
// Use manual bound parameters to speed things up
|
||||
var statement =
|
||||
Scholar.DB.getStatement("INSERT INTO itemData VALUES (?,?,?)");
|
||||
statement.bindInt32Parameter(0, this.getID());
|
||||
|
||||
for (fieldID in this._changedItemData.items){
|
||||
if (!this.getField(fieldID)){
|
||||
continue;
|
||||
}
|
||||
|
||||
statement.bindInt32Parameter(0, this.getID());
|
||||
statement.bindInt32Parameter(1, fieldID);
|
||||
|
||||
if (Scholar.ItemFields.getID('accessDate')==fieldID
|
||||
|
@ -736,7 +738,7 @@ Scholar.Item.prototype.save = function(){
|
|||
else {
|
||||
statement.bindUTF8StringParameter(2, this.getField(fieldID));
|
||||
}
|
||||
statement.executeStep();
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
Scholar.History.add('itemData', 'itemID-fieldID',
|
||||
|
|
|
@ -90,7 +90,6 @@ Scholar.Fulltext = new function(){
|
|||
// Handle bound parameters manually for optimal speed
|
||||
var statement1 = Scholar.DB.getStatement("INSERT INTO fulltextWords (word) VALUES (?)");
|
||||
var statement2 = Scholar.DB.getStatement("INSERT OR IGNORE INTO fulltextItems VALUES (?,?)");
|
||||
statement2.bindInt32Parameter(1, itemID);
|
||||
|
||||
for each(var word in words){
|
||||
if (existing['_' + word]){
|
||||
|
@ -98,12 +97,13 @@ Scholar.Fulltext = new function(){
|
|||
}
|
||||
else {
|
||||
statement1.bindUTF8StringParameter(0, word);
|
||||
statement1.executeStep()
|
||||
statement1.execute()
|
||||
var wordID = Scholar.DB.getLastInsertID();
|
||||
}
|
||||
|
||||
statement2.bindInt32Parameter(0, wordID);
|
||||
statement2.executeStep();
|
||||
statement2.bindInt32Parameter(1, itemID);
|
||||
statement2.execute();
|
||||
}
|
||||
|
||||
statement1.reset();
|
||||
|
|
Loading…
Add table
Reference in a new issue