/updateStatus.js (99b21aa86e56024cc770a95a8a1128aecd515422) (2416 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.js");
const m=require("dayjs");
let opts = require("./creds")["SQLITE3"];
opts.connectCallback = (database) => {
// Prep the databse to update each case as we get its updated info:
let dao = new DAO.CaseCtlr(database);
dao.stmts.update = dao.prepare(
database,
"UPDATE cases SET filed_Date = $fd, case_status = $status WHERE casenumber = $cnum"
);
// Track all the update promises, then wait until they're done:
let promises = [];
Case.sqlAllCases({
database: database,
query: "SELECT case_URL FROM cases WHERE case_status IS NULL OR case_status = 'Active' OR filed_Date IS NULL LIMIT 100",
// This is the callback used for each case:
rowCallback: caseObj => {
promises.push(
// Load the data from the website, then
caseObj.loadCaseFromURL()
.then(caseO => {
// store it into the database:
caseO.storeSQL(database);
(caseO.caseNumber && caseO.filedDate && caseO.caseStatus) &&
dao.update({
$cnum: caseO.caseNumber,
$fd: (new m(caseO.filedDate).format("YYYY-MM-DD")),
$status: caseO.caseStatus
});
})
.catch(e => { console.error("loadCaseFromURL", caseObj, e); })
);
},
completionCallback: () => {
console.log("Updating", promises.length, "cases.");
// 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();
dao.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 |
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 |
- |
446eab412997373a9912a19eb8248a50457917da |
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 |
2779 |
8e0bfad2a57a7873bc1ef62b9f40cd41bdc7b636 |
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