/updateAddress.js (7d2bdf38b346200af44c3c5c6025782119e5e66e) (2754 bytes) (mode 100644) (type blob)
/*
This file is part of datajams-evictions.
datajams-evictions is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
datajams-evictions is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with datajams-evictions. If not, see <https://www.gnu.org/licenses/>.
Copyright 2020 Luigi Bai
*/
const DAO = require("./lib/sqlDAO");
const Case = require("./lib/Case.class");
const OdysseyInfo = require("./lib/OdysseyInfo.class");
let opts = require("./creds")["SQLITE3"];
opts.connectCallback = (database) => {
// Prep the databse to update each case as we get its updated info:
let pDao = new DAO.PartyCtlr(database);
pDao.stmts.update = pDao.prepare(
database,
"UPDATE party SET party_address = $pa WHERE casenumber = $cnum AND party_role = $pr AND party_name = $pn"
);
let cDao = new DAO.CaseCtlr(database);
cDao.stmts.update = cDao.prepare(
database,
"UPDATE cases SET odyssey_ID = $oid WHERE casenumber = $cnum"
);
// Track all the update promises, then wait until they're done:
let promises = [];
database.each(
"SELECT casenumber as caseNumber FROM cases WHERE casenumber IS NOT NULL AND odyssey_ID IS NULL ORDER BY casenumber DESC LIMIT 10",
// This is the callback used for each case:
(err, caseObj) => {
if (! caseObj.caseNumber) console.error("Database had case with no casenuber.");
else {
promises.push(
// Grab the
(new OdysseyInfo(caseObj.caseNumber))
.findCasePromise()
.then(oi => {
// Store the OdysseyID into Cases
cDao.update({
$cnum: oi.caseNumber,
$oid: oi.caseID
});
// Store the party addresses
oi.parties.forEach(party => {
pDao.update({
$pa: party.address.join(" "),
$cnum: oi.caseNumber,
$pr: party.role,
$pn: party.name
});
});
})
.catch(err => {
console.error("Error retrieving OI", caseObj, err);
})
);
}
},
() => {
// And this is the callback used when the SELECT is finished:
Promise.all(promises)
.finally(() => {
// Shut down the database, and the HTTPS agent:
require("./lib/httpOptions").getGlobalAgent().destroy();
pDao.finalize();
cDao.finalize();
DAO.disconnect(database);
})
;
}
);
};
DAO.connect(opts);
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
31 |
ce60eb947708d4530bee8739c111f9c0ab750eaa |
.gitignore |
100644 |
blob |
33877 |
e37e32e4e836c2394b62c0a848c2094f687eb530 |
LICENSE |
100644 |
blob |
1171 |
354a297411cdddbe0355507766510a182aba0874 |
Promise.shim.js |
100644 |
blob |
790 |
22bcce7bc95fa3269ec92cb40ec4df524dff7e46 |
README.md |
100644 |
blob |
364 |
c97984072c2cd4c8daa74c3e6ff6eb0434dc5d72 |
creds.example.js |
040000 |
tree |
- |
9a1098d354ac9e8c9329a1000b337052173cfac2 |
lib |
100644 |
blob |
3383 |
9bc256e982b5cf6186c0501e960826b71b78016b |
loadDockets.js |
100644 |
blob |
49738 |
d6ac529ef6f7718e7bb1770f5544f35238738473 |
package-lock.json |
100644 |
blob |
627 |
1dbf524b42fda0760f06490e6c8dd142cab2308c |
package.json |
100644 |
blob |
2130 |
69eac4aecd2ae8d90fb05de3e27156fd8a0d590d |
schema.mssql.sql |
100644 |
blob |
1032 |
dd314aae1344ab599bf5ad4a79b64e3f129a6abb |
schema.sqlite3.sql |
100644 |
blob |
1608 |
1086eccf9183298d0fdedf88b8bc19c9a6159278 |
searchNames.js |
100755 |
blob |
162 |
7c25a482064c9580388f09c4d91683f3858ff7ca |
sqdump |
100644 |
blob |
2754 |
7d2bdf38b346200af44c3c5c6025782119e5e66e |
updateAddress.js |
100644 |
blob |
2181 |
66cb76343f7b83906ea940e9a5ccf90ce7f024e1 |
updateStatus.js |
100644 |
blob |
6576 |
67a852a1d29d13ecbea36711fea8ba8b3bd18fcf |
xferData.js |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/datajams-lbai/datajams-evictions
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/datajams-lbai/datajams-evictions
Clone this repository using git:
git clone git://git.rocketgit.com/user/datajams-lbai/datajams-evictions
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main