/updateAddress.js (0beff714ed634a1763dbf0f2b3b1a3a049b4c258) (3348 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 rowLimit = 25;
if (process.argv.length > 2) {
let n = Number(process.argv[2]);
if (!Number.isNaN(n) && n.valueOf() > 0) rowLimit = n.valueOf();
}
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"
);
pDao.ignoreInsertErrors = true;
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 "+rowLimit,
// 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 => {
if (party.address) {
// If this has been a bulk extract,
// probably should insert first, given
// the bulk extracts only have 2 parties
// per case.
pDao.insert({
$addr: party.address.join(" "),
$cnum: oi.caseNumber,
$role: party.role,
$name: party.name
});
pDao.update({
$pa: party.address.join(" "),
$cnum: oi.caseNumber,
$pr: party.role,
$pn: party.name
});
}
});
})
.catch(err => {
console.error("Error retrieving OI", caseObj, err);
})
);
}
},
() => {
console.log("Updating", promises.length, "addresses.");
// And this is the callback used when the SELECT is finished:
Promise.all(promises)
.finally(() => {
// Shut down the database, and the HTTPS agent:
pDao.finalize();
cDao.finalize();
DAO.disconnect(database);
require("./lib/httpOptions").getGlobalAgent().destroy();
})
;
}
);
};
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 |
1710 |
7dcf242a339081ab4c71cde50af7195a3eb26843 |
README.md |
100644 |
blob |
364 |
c97984072c2cd4c8daa74c3e6ff6eb0434dc5d72 |
creds.example.js |
100644 |
blob |
1410 |
bc1777db47110f7e7bfdfee7895204fbfa0f68ba |
extractFile.js |
100644 |
blob |
2009 |
530f6b3bddfca745b628f7a4a226796d17a18605 |
extractMonth.js |
040000 |
tree |
- |
5ce9dfb0e5de00a3eafb5e110b8cd69dc38f08d1 |
lib |
100644 |
blob |
3387 |
d9081a5bae4b71e3a4f932769caef902f079fa20 |
loadDockets.js |
100644 |
blob |
49735 |
4e6be3f3100b172d1571d6ddf21eeabe70876b5c |
package-lock.json |
100644 |
blob |
626 |
129b1f2d2524cefe2b3ab9aa4eacae3ad9748089 |
package.json |
100644 |
blob |
4159 |
888ba8ce11fdf4d3e1d197ef755e74ee1e7af1d9 |
schema.mssql.sql |
100644 |
blob |
3367 |
a05db9482fe6f9fc3c2f275d697543332b3d4a0d |
schema.sqlite3.sql |
100644 |
blob |
2349 |
334eca19c709741ee6a386fe4c9527c3ac1b0b4d |
searchNames.js |
100755 |
blob |
162 |
7c25a482064c9580388f09c4d91683f3858ff7ca |
sqdump |
100644 |
blob |
3348 |
0beff714ed634a1763dbf0f2b3b1a3a049b4c258 |
updateAddress.js |
100644 |
blob |
3915 |
77c7694889dcc3c422bff5c1ebc15ccd0c366e4c |
updateDates.ms.sql |
100644 |
blob |
3663 |
af9d94ba2bf7fbaf736c02e433b89248f3fbad13 |
updateDates.sqlite.sql |
100644 |
blob |
2416 |
99b21aa86e56024cc770a95a8a1128aecd515422 |
updateStatus.js |
100644 |
blob |
6799 |
dba4385e740197b0fe1e19c89a39052ab799bdb0 |
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