description:"**"+req.body.username+"** "+(req.body.operation==="FINISH"?" has finished collecting "+req.body.required+" / "+req.body.required+" __"+req.body.item_name+"__!":
req.body.operation==="INCREASE"?" has collected "+req.body.obtained+" / "+req.body.required+" __"+req.body.item_name+"__ (+"+(req.body.obtained-req.body.previous_amt)+")"
:" has set __"+req.body.item_name+"__ to "+req.body.obtained+" / "+req.body.required)+"\n\n[Sig Planner - Sig crafts all the things](http://projectdivar.com:3001)"
returndb.query("insert into audit_log(username,obtained,required,item_name,operation,date,previous_amt) values($1,$2,$3,$4,$5,$6,$7)",[req.body.username,req.body.obtained,req.body.required,req.body.item_name,req.body.operation,req.body.last_modified,req.body.previous_amt])
db.query('insert into crafting_list(itemid,name,obtained,required,icon) values($1,$2,$3,$4,$5)',[req.body.itemid,req.body.name,req.body.obtained,req.body.required,req.body.icon])
.then((data)=>{
res.status(200).send("Yay!")
})
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
db.query('update crafting_list set required=$1 where itemid=$2',[Number(data.rows[0].required)+Number(req.body.required),req.body.itemid])
awaitdb.query('select * from crafting_list where itemid=$1',[req.body.itemid])
.then((data)=>{
if(data.rows.length>0){
db.query('update crafting_list set obtained=$1 where itemid=$2',[Math.min(data.rows[0].required,Number(data.rows[0].obtained)+Number(req.body.obtained)),req.body.itemid])