From ea982715735577fef741bd4de857c526f48dc857 Mon Sep 17 00:00:00 2001 From: William Allen <16820599+williamjallen@users.noreply.github.com> Date: Fri, 7 Feb 2025 13:12:30 -0500 Subject: [PATCH] Remove `dailyupdatefile` table (#2703) The `dailyupdatefile` table is currently only used to display a list of users who have committed to the project recently but don't have a CDash account. As we rethink what it means for CDash to be integrated with version control systems, it seems unlikely that we will want CDash to be responsible for interacting with version control systems directly, instead relying upon CTest to include the necessary information in the Update step. --- app/Console/Commands/CleanDatabase.php | 1 - .../ManageProjectRolesController.php | 50 ------------------- app/cdash/app/Model/Project.php | 7 --- app/cdash/include/dailyupdates.php | 33 ------------ app/cdash/public/manageProjectRoles.xsl | 18 ------- app/cdash/tests/test_removebuilds.php | 11 ---- ...2_06_220212_drop_dailyupdatefile_table.php | 29 +++++++++++ phpstan-baseline.neon | 22 +++----- 8 files changed, 35 insertions(+), 136 deletions(-) create mode 100644 database/migrations/2025_02_06_220212_drop_dailyupdatefile_table.php diff --git a/app/Console/Commands/CleanDatabase.php b/app/Console/Commands/CleanDatabase.php index 97f75e36a4..bef6f71b77 100644 --- a/app/Console/Commands/CleanDatabase.php +++ b/app/Console/Commands/CleanDatabase.php @@ -37,7 +37,6 @@ public function handle(): void DatabaseCleanupUtils::deleteUnusedRows('buildfailuredetails', 'id', 'buildfailure', 'detailsid'); DatabaseCleanupUtils::deleteUnusedRows('configure', 'id', 'build2configure', 'configureid'); DatabaseCleanupUtils::deleteUnusedRows('coveragefile', 'id', 'coverage', 'fileid'); - DatabaseCleanupUtils::deleteUnusedRows('dailyupdatefile', 'dailyupdateid', 'dailyupdate'); DatabaseCleanupUtils::deleteUnusedRows('note', 'id', 'build2note', 'noteid'); DatabaseCleanupUtils::deleteUnusedRows('testoutput', 'id', 'build2test', 'outputid'); DatabaseCleanupUtils::deleteUnusedRows('uploadfile', 'id', 'build2uploadfile', 'fileid'); diff --git a/app/Http/Controllers/ManageProjectRolesController.php b/app/Http/Controllers/ManageProjectRolesController.php index df89d281f1..14e842a62f 100644 --- a/app/Http/Controllers/ManageProjectRolesController.php +++ b/app/Http/Controllers/ManageProjectRolesController.php @@ -329,56 +329,6 @@ public function viewPage(): View|RedirectResponse $xml .= ''; } - - if (is_array($project_array)) { - // Check if a user is committing without being registered to CDash or with email disabled - $date = date(FMT_DATETIME, strtotime(date(FMT_DATETIME) . ' -30 days')); - $query = $db->executePrepared(' - SELECT DISTINCT - author, - emailtype, - u.email - FROM - dailyupdate, - dailyupdatefile - LEFT JOIN user2repository ON ( - dailyupdatefile.author=user2repository.credential - AND ( - user2repository.projectid=0 - OR user2repository.projectid=? - ) - ) - LEFT JOIN user2project ON ( - user2repository.userid= user2project.userid - AND user2project.projectid=? - ) - LEFT JOIN users AS u ON ( - user2project.userid=u.id - ) - WHERE - dailyupdatefile.dailyupdateid=dailyupdate.id - AND dailyupdate.projectid=? - AND dailyupdatefile.checkindate>? - AND ( - emailtype=0 - OR emailtype IS NULL - ) - ', [ - intval($project_array['id']), - intval($project_array['id']), - intval($project_array['id']), - $date, - ]); - - add_last_sql_error('ManageProjectRole'); - foreach ($query as $query_array) { - $xml .= ''; - $xml .= add_XML_value('author', $query_array['author']); - $xml .= add_XML_value('emailtype', $query_array['emailtype']); - $xml .= add_XML_value('email', $query_array['email']); - $xml .= ''; - } - } } if ((bool) config('require_full_email_when_adding_user')) { diff --git a/app/cdash/app/Model/Project.php b/app/cdash/app/Model/Project.php index 074c5952ac..eedba8f36f 100644 --- a/app/cdash/app/Model/Project.php +++ b/app/cdash/app/Model/Project.php @@ -202,13 +202,6 @@ public function Delete(): bool DB::delete('DELETE FROM labelemail WHERE projectid=?', [intval($this->Id)]); DB::delete('DELETE FROM project2repositories WHERE projectid=?', [intval($this->Id)]); - $dailyupdate = DB::select('SELECT id FROM dailyupdate WHERE projectid=?', [intval($this->Id)]); - $dailyupdate_ids = []; - foreach ($dailyupdate as $dailyupdate_array) { - $dailyupdate_ids[] = (int) $dailyupdate_array->id; - } - DB::table('dailyupdatefile')->whereIn('dailyupdateid', $dailyupdate_ids)->delete(); - DB::delete('DELETE FROM dailyupdate WHERE projectid=?', [intval($this->Id)]); DB::delete('DELETE FROM build_filters WHERE projectid=?', [intval($this->Id)]); diff --git a/app/cdash/include/dailyupdates.php b/app/cdash/include/dailyupdates.php index ce474f63dc..fc97643f9d 100644 --- a/app/cdash/include/dailyupdates.php +++ b/app/cdash/include/dailyupdates.php @@ -982,44 +982,11 @@ function addDailyChanges(int $projectid): void // Insert the commits foreach ($commits as $commit) { - $filename = $commit['directory'] . '/' . $commit['filename']; - $checkindate = $commit['time']; $author = addslashes($commit['author']); - $email = ''; - if (isset($commit['email'])) { - $email = addslashes($commit['email']); - } - $log = addslashes($commit['comment']); - $revision = $commit['revision']; - $priorrevision = $commit['priorrevision']; if (!in_array(stripslashes($author), $cvsauthors)) { $cvsauthors[] = stripslashes($author); } - - $db->executePreparedSingleRow(' - INSERT INTO dailyupdatefile ( - dailyupdateid, - filename, - checkindate, - author, - email, - log, - revision, - priorrevision - ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?) - ', [ - $updateid, - $filename, - $checkindate, - $author, - $email, - $log, - $revision, - $priorrevision, - ]); - add_last_sql_error('addDailyChanges', $projectid); } // If the project has the option to send an email to the author diff --git a/app/cdash/public/manageProjectRoles.xsl b/app/cdash/public/manageProjectRoles.xsl index 2e29e5627e..cfc3376f2a 100644 --- a/app/cdash/public/manageProjectRoles.xsl +++ b/app/cdash/public/manageProjectRoles.xsl @@ -114,24 +114,6 @@
- - - -
- - - - - * () doesn't want to receive emails but has been submitting in the past month. - - - * is not registered for this project but has been submitting in the past month. - - -
-
-
-
diff --git a/app/cdash/tests/test_removebuilds.php b/app/cdash/tests/test_removebuilds.php index a5e25388fe..fd956a5d65 100644 --- a/app/cdash/tests/test_removebuilds.php +++ b/app/cdash/tests/test_removebuilds.php @@ -414,16 +414,6 @@ public function testBuildRemovalWorksAsExpected(): void 'status' => 0, 'revision' => 'DEADBEEF', ]); - DB::table('dailyupdatefile')->insert([ - 'dailyupdateid' => $dailyupdate_id, - 'filename' => 'test_removebuilds.php', - 'checkindate' => $time, - 'author' => 'CDash', - 'email' => 'admin@cdash.org', - 'log' => 'test_removebuilds.php', - 'revision' => 'DEADBEEF', - 'priorrevision' => '00000000', - ]); $image_id = DB::table('image')->insertGetId([ 'img' => 'asdf', 'extension' => 'png', @@ -455,7 +445,6 @@ public function testBuildRemovalWorksAsExpected(): void $this->verify('configure', 'id', '=', $configure_id, 0, $extra_msg); $this->verify('coveragefile', 'id', '=', $coveragefile_id, 0, $extra_msg); $this->verify('dailyupdate', 'id', '=', $dailyupdate_id, 0, $extra_msg); - $this->verify('dailyupdatefile', 'dailyupdateid', '=', $dailyupdate_id, 0, $extra_msg); $this->verify('image', 'id', '=', $image_id, 0, $extra_msg); $this->verify('note', 'id', '=', $note_id, 0, $extra_msg); $this->verify('testoutput', 'id', '=', $testoutput_id, 0, $extra_msg); diff --git a/database/migrations/2025_02_06_220212_drop_dailyupdatefile_table.php b/database/migrations/2025_02_06_220212_drop_dailyupdatefile_table.php new file mode 100644 index 0000000000..de6d928b35 --- /dev/null +++ b/database/migrations/2025_02_06_220212_drop_dailyupdatefile_table.php @@ -0,0 +1,29 @@ +integer('dailyupdateid')->default(0)->index(); + $table->string('filename')->default(''); + $table->timestamp('checkindate')->default(DB::raw('CURRENT_TIMESTAMP')); + $table->string('author')->default('')->index(); + $table->string('email')->default(''); + $table->text('log'); + $table->string('revision', 60)->default('0'); + $table->string('priorrevision', 60)->default('0'); + }); + } + } +}; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cc4d1a9be6..8b78a51952 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1747,7 +1747,7 @@ parameters: - message: "#^Argument of an invalid type array\\|false supplied for foreach, only iterables are supported\\.$#" - count: 5 + count: 4 path: app/Http/Controllers/ManageProjectRolesController.php - @@ -1760,7 +1760,7 @@ parameters: #^Call to deprecated function add_last_sql_error\\(\\)\\: 04/22/2023$# """ - count: 3 + count: 2 path: app/Http/Controllers/ManageProjectRolesController.php - @@ -1784,7 +1784,7 @@ parameters: #^Call to deprecated method executePrepared\\(\\) of class CDash\\\\Database\\: 04/22/2023 Use Laravel query builder or Eloquent instead$# """ - count: 5 + count: 4 path: app/Http/Controllers/ManageProjectRolesController.php - @@ -1914,21 +1914,11 @@ parameters: - message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#" - count: 4 - path: app/Http/Controllers/ManageProjectRolesController.php - - - - message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" count: 1 path: app/Http/Controllers/ManageProjectRolesController.php - - message: "#^Parameter \\#2 \\$timestamp of function date expects int\\|null, int\\|false given\\.$#" - count: 1 - path: app/Http/Controllers/ManageProjectRolesController.php - - - - message: "#^Variable \\$project_array might not be defined\\.$#" + message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" count: 1 path: app/Http/Controllers/ManageProjectRolesController.php @@ -13858,7 +13848,7 @@ parameters: #^Call to deprecated function add_last_sql_error\\(\\)\\: 04/22/2023$# """ - count: 3 + count: 2 path: app/cdash/include/dailyupdates.php - @@ -13882,7 +13872,7 @@ parameters: #^Call to deprecated method executePreparedSingleRow\\(\\) of class CDash\\\\Database\\: 04/22/2023 Use Laravel query builder or Eloquent instead$# """ - count: 8 + count: 7 path: app/cdash/include/dailyupdates.php -