From ed68984f5554b61cba695268a617d9674bed6bc5 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 9 Aug 2021 05:29:00 -0500 Subject: [PATCH] Add new patch updates --- ngsplanner_patch.sql | 5 + ngsplanner_schema.sql | 8 +- ngsplanner_seed.sql | 118 ++++++++++++------------ server.js | 207 +++++++++++++++++++++--------------------- 4 files changed, 174 insertions(+), 164 deletions(-) create mode 100644 ngsplanner_patch.sql diff --git a/ngsplanner_patch.sql b/ngsplanner_patch.sql new file mode 100644 index 0000000..4a2d855 --- /dev/null +++ b/ngsplanner_patch.sql @@ -0,0 +1,5 @@ +/*9 Aug Database Patch*/ +alter table potential add column description text; +alter table weapon_existence_data add column icon text; +alter table weapon_type add column shorthand text; +alter table weapon_existence_data add column special_name text; \ No newline at end of file diff --git a/ngsplanner_schema.sql b/ngsplanner_schema.sql index 5c790a8..032ceef 100644 --- a/ngsplanner_schema.sql +++ b/ngsplanner_schema.sql @@ -77,6 +77,7 @@ CREATE TABLE "weapon" ( CREATE TABLE "weapon_type" ( "id" SERIAL UNIQUE PRIMARY KEY, "name" text, + "shorthand" text, "icon" text, "dmg_type" int ); @@ -84,7 +85,8 @@ CREATE TABLE "weapon_type" ( CREATE TABLE "potential" ( "id" SERIAL UNIQUE PRIMARY KEY, "name" text, - "icon" text + "icon" text, + "description" text ); CREATE TABLE "potential_data" ( @@ -239,7 +241,9 @@ CREATE TABLE "weapon_existence_data" ( "weapon_type_id" int, "weapon_id" int, "popularity" int, - "editors_choice" int + "editors_choice" int, + "icon" text, + "special_name" text ); CREATE TABLE "augment_type" ( diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 99f84b9..896c48a 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -53,17 +53,17 @@ insert into weapon_type(name,icon,dmg_type) values('Rod','/icons/NGSUIItemRodMin insert into weapon_type(name,icon,dmg_type) values('Talis','/icons/NGSUIItemTalisMini.png',2); insert into weapon_type(name,icon,dmg_type) values('Wand','/icons/NGSUIItemWandMini.png',2); -insert into potential(name,icon) values('Recycler Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Indomitable Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Defensive Formation','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Offensive Formation','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Bastion Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Meditation Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Mustered Might Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Dynamo Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Berserk Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Wellspring Unit','/icons/NGSUIItemPotentialAbility.png'); -insert into potential(name,icon) values('Endurance Unit','/icons/NGSUIItemPotentialAbility.png'); +insert into potential(name,icon,description) values('Recycler Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Recycler Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Indomitable Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Indomitable Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Defensive Formation','/icons/NGSUIItemPotentialAbility.png','Test description for Defensive Formation. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Offensive Formation','/icons/NGSUIItemPotentialAbility.png','Test description for Offensive Formation. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Bastion Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Bastion Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Meditation Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Meditation Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Mustered Might Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Mustered Might Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Dynamo Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Dynamo Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Berserk Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Berserk Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Wellspring Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Wellspring Unit. Provides {mel_dmg}% melee dmg'); +insert into potential(name,icon,description) values('Endurance Unit','/icons/NGSUIItemPotentialAbility.png','Test description for Endurance Unit. Provides {mel_dmg}% melee dmg'); insert into class_level_data(class_id,name,level,hp,atk,def) values((SELECT id from class WHERE name='Hunter' limit 1),'Hunter Lv.1',1,300,450,304); @@ -101,54 +101,54 @@ insert into potential_data(potential_id,name,level,mel_dmg,rng_dmg,tec_dmg,crit_ insert into potential_data(potential_id,name,level,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build) values((select id from potential where name='Indomitable Unit' limit 1),'Indomitable Unit Lv.1',1,1.18,1.18,1.18,0,0,0,0,0,0,1.10,0,0,0,0,0,0,10,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Sword' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Spear' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Wired Lance' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Twin Dagger' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Double Saber' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Knuckles' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Assault Rifle' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Launcher' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Twin Machine Guns' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Rod' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Talis' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Wand' limit 1),(select id from weapon where name='Primm' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Sword' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Spear' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Wired Lance' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Twin Dagger' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Double Saber' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Knuckles' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Assault Rifle' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Launcher' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Twin Machine Guns' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Rod' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Talis' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); -insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice) - values((select id from weapon_type where name='Wand' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Sword' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Spear' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Wired Lance' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Twin Dagger' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Double Saber' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Knuckles' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Assault Rifle' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Launcher' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Twin Machine Guns' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Rod' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Talis' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Wand' limit 1),(select id from weapon where name='Primm' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Sword' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Spear' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Wired Lance' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Twin Dagger' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Double Saber' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Knuckles' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Assault Rifle' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Launcher' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Twin Machine Guns' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Rod' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Talis' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); +insert into weapon_existence_data(weapon_type_id,weapon_id,popularity,editors_choice,icon) + values((select id from weapon_type where name='Wand' limit 1),(select id from weapon where name='Tzvia' limit 1),0,0,''); insert into roles(name) diff --git a/server.js b/server.js index e80f848..5250f29 100644 --- a/server.js +++ b/server.js @@ -212,32 +212,61 @@ const ENDPOINTDATA=[ } ] -app.get(PREFIX+"/databases",(req,res)=>{ - db.query('select * from pg_database where datname like \'ngsplanner%\' order by datname desc limit 100') - .then((data)=>{ - res.status(200).json(data.rows) - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) -}) - -app.post(PREFIX+"/databases/restorefrombackup",(req,res)=>{ - if (req.body.database) { - db3.query('select * from pg_database where datname=$1',[req.body.database]) +for (var test of ["","/test"]) { + app.get(PREFIX+test+"/databases",(req,res)=>{ + db.query('select * from pg_database where datname like \'ngsplanner%\' order by datname desc limit 100') .then((data)=>{ - if (data.rows.length>0) { - db.end(()=>{}) - return db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') - } else { - throw "Could not find requested database "+req.body.database - } + res.status(200).json(data.rows) }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + }) + + app.post(PREFIX+test+"/databases/restorefrombackup",(req,res)=>{ + if (req.body.database) { + db3.query('select * from pg_database where datname=$1',[req.body.database]) + .then((data)=>{ + if (data.rows.length>0) { + db.end(()=>{}) + return db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') + } else { + throw "Could not find requested database "+req.body.database + } + }) + .then(()=>{ + return db3.query('drop database ngsplanner') + }) + .then(()=>{ + return db3.query('create database ngsplanner with template '+req.body.database) + }) + .then(()=>{ + db = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner', + port: 5432, + }) + res.status(200).send("Done!") + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } else { + res.status(500).send("Invalid data!") + } + }) + app.post(PREFIX+test+"/databases/testtolive",(req,res)=>{ + db.end(()=>{}) + db2.end(()=>{}) + db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'') .then(()=>{ - return db3.query('drop database ngsplanner') + return db3.query('drop database ngsplanner') }) .then(()=>{ - return db3.query('create database ngsplanner with template '+req.body.database) + return db3.query('create database ngsplanner with template ngsplanner2') }) .then(()=>{ db = new Pool({ @@ -247,103 +276,75 @@ app.post(PREFIX+"/databases/restorefrombackup",(req,res)=>{ database: 'ngsplanner', port: 5432, }) + db2 = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner2', + port: 5432, + }) res.status(200).send("Done!") }) .catch((err)=>{ console.log(err.message) res.status(500).send(err.message) }) - } else { - res.status(500).send("Invalid data!") - } -}) - -app.post(PREFIX+"/databases/testtolive",(req,res)=>{ - db.end(()=>{}) - db2.end(()=>{}) - db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'') - .then(()=>{ - return db3.query('drop database ngsplanner') - }) - .then(()=>{ - return db3.query('create database ngsplanner with template ngsplanner2') }) - .then(()=>{ - db = new Pool({ - user: 'postgres', - password: '', - host: 'postgres', - database: 'ngsplanner', - port: 5432, + + app.post(PREFIX+test+"/databases/livetotest",(req,res)=>{ + db.end(()=>{}) + db2.end(()=>{}) + db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'') + .then(()=>{ + return db3.query('drop database ngsplanner2') }) - db2 = new Pool({ - user: 'postgres', - password: '', - host: 'postgres', - database: 'ngsplanner2', - port: 5432, + .then(()=>{ + return db3.query('create database ngsplanner2 with template ngsplanner') }) - res.status(200).send("Done!") - }) - .catch((err)=>{ - console.log(err.message) - res.status(500).send(err.message) - }) -}) - -app.post(PREFIX+"/databases/livetotest",(req,res)=>{ - db.end(()=>{}) - db2.end(()=>{}) - db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'') - .then(()=>{ - return db3.query('drop database ngsplanner2') - }) - .then(()=>{ - return db3.query('create database ngsplanner2 with template ngsplanner') - }) - .then(()=>{ - db = new Pool({ - user: 'postgres', - password: '', - host: 'postgres', - database: 'ngsplanner', - port: 5432, + .then(()=>{ + db = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner', + port: 5432, + }) + db2 = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner2', + port: 5432, + }) + res.status(200).send("Done!") }) - db2 = new Pool({ - user: 'postgres', - password: '', - host: 'postgres', - database: 'ngsplanner2', - port: 5432, + .catch((err)=>{ + res.status(500).send(err.message) }) - res.status(200).send("Done!") - }) - .catch((err)=>{ - res.status(500).send(err.message) }) -}) -app.post(PREFIX+"/databases/backup",(req,res)=>{ - db.end(()=>{}) - var date = new Date() - db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') - .then(()=>{ - return db3.query('create database ngsplanner'+String(date.getFullYear()).padStart(4,'0')+String(date.getMonth()).padStart(2,'0')+String(date.getDate()).padStart(2,'0')+String(date.getHours()).padStart(2,'0')+String(date.getMinutes()).padStart(2,'0')+String(date.getSeconds()).padStart(2,'0')+' with template ngsplanner') - }) - .then(()=>{ - db = new Pool({ - user: 'postgres', - password: '', - host: 'postgres', - database: 'ngsplanner', - port: 5432, + app.post(PREFIX+test+"/databases/backup",(req,res)=>{ + db.end(()=>{}) + var date = new Date() + db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') + .then(()=>{ + return db3.query('create database ngsplanner'+String(date.getFullYear()).padStart(4,'0')+String(date.getMonth()).padStart(2,'0')+String(date.getDate()).padStart(2,'0')+String(date.getHours()).padStart(2,'0')+String(date.getMinutes()).padStart(2,'0')+String(date.getSeconds()).padStart(2,'0')+' with template ngsplanner') + }) + .then(()=>{ + db = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner', + port: 5432, + }) + res.status(200).send("Done!") + }) + .catch((err)=>{ + res.status(500).send(err.message) }) - res.status(200).send("Done!") - }) - .catch((err)=>{ - res.status(500).send(err.message) }) -}) +} function CreateDynamicEndpoints() { ENDPOINTDATA.forEach((endpoint)=>{