diff --git a/lib/TclUpdates/SQLiteWriter.php b/lib/TclUpdates/SQLiteWriter.php index 061e160..aee1836 100755 --- a/lib/TclUpdates/SQLiteWriter.php +++ b/lib/TclUpdates/SQLiteWriter.php @@ -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, )); diff --git a/parse_files.php b/parse_files.php index 19fa141..19a14af 100755 --- a/parse_files.php +++ b/parse_files.php @@ -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); } } diff --git a/sql/dbschema.sql b/sql/dbschema.sql index ec43990..c63586e 100644 --- a/sql/dbschema.sql +++ b/sql/dbschema.sql @@ -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 field + "seenDate" INTEGER, -- date added to db "pubDate" INTEGER, -- published date "publisher" TEXT, -- publisher + "num_files" INTEGER, -- number of files total "fwId" TEXT, -- (CHANGES FOR THE SAME FILE_ID!!!) MAYBE MOVE TO update_map "file_id" TEXT, -- 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 -);