mirror of
https://github.com/mbirth/tcl_update_db.git
synced 2024-11-09 23:06:45 +00:00
Restructure database. Also derive seenDate from filename (stamp).
This commit is contained in:
parent
6d8f3bda7b
commit
7deee59c3a
@ -86,8 +86,11 @@ class SQLiteWriter
|
||||
}
|
||||
}
|
||||
|
||||
public function addGotu(GotuObject $g)
|
||||
public function addGotu(GotuObject $g, $seenDate = false)
|
||||
{
|
||||
if ($seenDate === false) {
|
||||
$seenDate = gmdate('c');
|
||||
}
|
||||
$this->addFile(array(
|
||||
'file_sha1' => $g->file_chksum,
|
||||
'file_name' => $g->filename,
|
||||
@ -103,10 +106,14 @@ class SQLiteWriter
|
||||
'pubDate' => $g->time,
|
||||
));
|
||||
$ok = $this->insertArray('updates', array(
|
||||
'curef' => $g->curef,
|
||||
'update_desc' => $g->update_desc,
|
||||
'svn' => $g->svn,
|
||||
'seenDate' => $seenDate,
|
||||
'pubDate' => $g->time,
|
||||
'publisher' => $g->publisher,
|
||||
'fwId' => $g->fw_id,
|
||||
'num_files' => $g->fileset_count,
|
||||
'file_id' => $g->file_id,
|
||||
'file_sha1' => $g->file_chksum,
|
||||
));
|
||||
|
@ -14,6 +14,8 @@ $sqlw = new SQLiteWriter();
|
||||
|
||||
foreach ($file_list as $file) {
|
||||
$filename = basename($file);
|
||||
$file_stamp = substr($filename, 0, strpos($filename, '.'));
|
||||
$file_date = gmdate('c', intval($file_stamp));
|
||||
$data = file_get_contents($file);
|
||||
$xp = new XmlParser();
|
||||
$load_ok = $xp->loadXmlFromString($data);
|
||||
@ -27,8 +29,8 @@ foreach ($file_list as $file) {
|
||||
}
|
||||
echo 'Processing ' . $filename . PHP_EOL;
|
||||
$g = GotuObject::fromXmlParser($xp);
|
||||
print_r($g);
|
||||
//print_r($g);
|
||||
if ($g->tv) {
|
||||
$sqlw->addGotu($g);
|
||||
$sqlw->addGotu($g, $file_date);
|
||||
}
|
||||
}
|
||||
|
@ -54,21 +54,19 @@ CREATE TABLE "files" (
|
||||
-- a separate "files" table might get introduced later
|
||||
CREATE TABLE "updates" (
|
||||
"updateId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"curef" TEXT, -- PRD number
|
||||
"update_desc" TEXT,
|
||||
"svn" TEXT, -- version info from <SVN> field
|
||||
"seenDate" INTEGER, -- date added to db
|
||||
"pubDate" INTEGER, -- published date
|
||||
"publisher" TEXT, -- publisher
|
||||
"num_files" INTEGER, -- number of files total
|
||||
"fwId" TEXT, -- <FW_ID> (CHANGES FOR THE SAME FILE_ID!!!) MAYBE MOVE TO update_map
|
||||
"file_id" TEXT, -- <FILE_ID> of first file
|
||||
"file_sha1" TEXT REFERENCES "files" ("sha1") -- SHA1 checksum of first file
|
||||
);
|
||||
CREATE UNIQUE INDEX "index_updates" ON "updates" (
|
||||
"curef",
|
||||
"fwId",
|
||||
"file_id"
|
||||
);
|
||||
|
||||
-- Maps update files to devices
|
||||
CREATE TABLE "update_map" (
|
||||
"deviceId" INTEGER REFERENCES "devices" ("deviceId"),
|
||||
"updateId" INTEGER REFERENCES "updates" ("updateId"),
|
||||
"seenDate" INTEGER -- timestamp when this record was added
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user