added a (badly formatted) delete button for process scheduler entries

pull/1/head
Michael Peter Christen 12 years ago
parent 2b563debbf
commit 179d032181

@ -171,8 +171,16 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<input type="hidden" name="scheduleeventaction" id="scheduleeventaction" value="false" />
<input type="hidden" name="current_pk" id="current_pk" value="" />
<input type="hidden" name="num" value="#[num]#" />
<input type="submit" name="execrows" value="Execute Selected Actions" />
<input type="submit" name="deleterows" value="Delete Selected Actions" />
&nbsp;<input type="submit" name="execrows" value="Execute Selected Actions" />&nbsp;&nbsp;&nbsp;
<input type="submit" name="deleterows" value="Delete Selected Actions" />&nbsp;&nbsp;&nbsp;
<table><tr><td><input type="submit" name="deleteold" value="Delete all Actions which had been created before " /></td><td><select name="deleteoldtime">
<option value="1">1 day</option><option value="2">2 days</option><option value="3">3 days</option>
<option value="4">4 days</option><option value="5">5 days</option><option value="6">6 days</option>
<option value="7">1 week</option><option value="14">2 weeks</option><option value="21">3 weeks</option>
<option value="30">1 month</option><option value="60" selected="selected">2 months</option><option value="90">3 months</option>
<option value="180">6 months</option><option value="270">9 months</option>
<option value="365">1 year</option><option value="730">2 years</option>
</select></td></tr></table>
</p>
</form>

@ -33,6 +33,7 @@ import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.WorkTables;
import net.yacy.kelondro.blob.Tables;
import net.yacy.kelondro.blob.Tables.Row;
import net.yacy.kelondro.logging.Log;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@ -156,6 +157,28 @@ public class Table_API_p {
}
}
}
if (post != null && !post.get("deleteold", "").isEmpty()) {
int days = post.getInt("deleteoldtime", 365);
try {
Iterator<Row> ri = sb.tables.iterator(WorkTables.TABLE_API_NAME);
Row row;
Date now = new Date();
Date limit = new Date(now.getTime() - 1000L * 60L * 60L * 24L * days);
List<byte[]> pkl = new ArrayList<byte[]>();
while (ri.hasNext()) {
row = ri.next();
Date d = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, now);
if (d.before(limit)) {
pkl.add(row.getPK());
}
}
for (byte[] pk: pkl) {
sb.tables.delete(WorkTables.TABLE_API_NAME, pk);
}
} catch (IOException e1) {
}
}
if (post != null && !post.get("execrows", "").isEmpty()) {
// create a time-ordered list of events to execute

Loading…
Cancel
Save