Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
APP_NAME=Testing
APP_ENV=testing
APP_KEY=base64:I9IIGKOLEXaZXIW2FrRe+XgfQPZEP/krNNIX1X86mCs=
APP_DEBUG=true
# APP_URL=http://localhost:8000

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file

PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

CACHE_DRIVER=array

LOG_CHANNEL=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
LOG_SQL=false

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=cRMKd3yNht

MAIL_MAILER=log
QUEUE_CONNECTION=sync
SESSION_DRIVER=array
TELESCOPE_ENABLED=false
GOOGLE_CLOUD_LOGGING_ENABLED=false
GOOGLE_CLOUD_PUBSUB_ENABLED=false
MEDIA_URL=http://media.url
JWT_SECRET=7DgKgfVvocDNrVzxXJPR3fkJuplN0PsIQ4PInjjbAEHRDmFLxwpHbvCbLPPtisiM
JWT_EXPIRATION=86400
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ composer.lock
tiltconf.json
_ide_helper.php
*~
application_default_credentials.json
application_default_credentials.json

**/caddy
frankenphp
frankenphp-worker.php
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ RUN apt-get update && apt-get install -y \
# Install Redis and Imagick
RUN wget -O redis-5.3.7.tgz 'http://pecl.php.net/get/redis-5.3.7.tgz' \
&& pecl install redis-5.3.7.tgz \
&& pecl install swoole \
&& rm -rf redis-5.3.7.tgz \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis \
&& docker-php-ext-enable gd \
&& docker-php-ext-enable swoole
&& docker-php-ext-enable gd

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --filename=composer

# Send update for php.ini
RUN curl https://frankenphp.dev/install.sh | sh \
&& mv frankenphp /usr/local/bin/frankenphp \
&& chmod +x /usr/local/bin/frankenphp

# Send update for php.ini
COPY ./init/php.development.ini /usr/local/etc/php/php.ini

# Copy the application
Expand All @@ -57,7 +59,6 @@ RUN composer install --optimize-autoloader \
&& php artisan optimize \
&& php artisan config:clear \
&& php artisan ide-helper:generate \
&& php artisan octane:install --server=swoole \
&& composer dumpautoload

# Generate Swagger
Expand All @@ -69,6 +70,8 @@ RUN php artisan l5-swagger:generate
# Add symbolic link for public file storage
RUN php artisan storage:link

RUN chmod +x vendor/bin/pint

COPY ./docker/start.sh /var/www/docker/start.sh
RUN chmod +x /var/www/docker/start.sh

Expand Down
5 changes: 1 addition & 4 deletions app/AliasReplyScanner/AliasReplyScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
use App\Models\Team;
use App\Models\User;
use App\Jobs\SendEmailJob;

use App\Models\EmailTemplate;
use App\Models\EnquiryThread;

use App\Models\EnquiryMessage;
use Webklex\PHPIMAP\ClientManager;

use EnquiriesManagementController as EMC;

class AliasReplyScanner
Expand Down Expand Up @@ -57,7 +54,7 @@ public function checkBodyIsSensible($text)
// Tokenize the text into words
$words = str_word_count($text, 1);

if(count($words) == 0) {
if (count($words) == 0) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/AddSuperAdminToAllTeams.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function handle()
{
$teamIds = Team::pluck("id");
$superAdminIds = User::where("is_admin", true)->pluck('id');
foreach($teamIds as $teamId) {
foreach($superAdminIds as $adminId) {
foreach ($teamIds as $teamId) {
foreach ($superAdminIds as $adminId) {
TeamHasUser::updateOrCreate(
[
'team_id' => $teamId,
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AliasReplyScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;

use App\Http\Traits\TeamTransformation;

use AliasReplyScanner as ARS;

class AliasReplyScanner extends Command
Expand Down Expand Up @@ -36,7 +34,7 @@ public function handle()
$messages = ARS::getNewMessagesSafe();
$this->info('Found ' . count($messages) . ' new messages');

foreach($messages as $i => $message) {
foreach ($messages as $i => $message) {
$this->info('Working on message #' . $i);
$this->processMessage($message);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/AssignTeamToCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function handle()
$teamMongoId = $item['team_id'];
$teamName = $item['team_name'];
$team = Team::where("mongo_object_id", $teamMongoId)->select("id")->first();
if(!$team && !is_null($teamName) && trim($teamName) !== '') {
if (!$team && !is_null($teamName) && trim($teamName) !== '') {
$team = Team::where("name", "like", "%".$teamName."%")->select("id")->first();
}
if(!$team) {
if (!$team) {
$team = $fallbackTeam;
}

Expand Down
1 change: 0 additions & 1 deletion app/Console/Commands/CleanTeamNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Console\Commands;

use App\Models\Team;

use App\Models\Dataset;
use App\Models\DatasetVersion;
use Illuminate\Console\Command;
Expand Down
2 changes: 0 additions & 2 deletions app/Console/Commands/DataProvidersPostMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
namespace App\Console\Commands;

use Exception;

use App\Models\Team;
use Illuminate\Console\Command;
use App\Models\DataProviderColl;
use App\Http\Traits\IndexElastic;

use App\Models\DataProviderCollHasTeam;

class DataProvidersPostMigration extends Command
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/DatasetLinkagesMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function handle()
foreach ($this->csvData as $csv) {
$sourceDataset = Dataset::where('mongo_object_id', $csv['source_mongo_object_id'])
->select('id')->first();
if(!$sourceDataset) {
if (!$sourceDataset) {
continue;
}
$targetDataset = Dataset::where('mongo_object_id', $csv['target_mongo_object_id'])
->select('id')->first();
if(!$targetDataset) {
if (!$targetDataset) {
continue;
}

Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/FAIRSharingScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use stdClass;
use Exception;

use App\Models\CommandConfig;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

Expand Down Expand Up @@ -68,7 +66,7 @@ public function handle(): void
private function runStep(stdClass $runStep): void
{
$response = null;
switch(strtolower($runStep->auth_type)) {
switch (strtolower($runStep->auth_type)) {
case 'bearer':
try {
$response = Http::withHeaders([
Expand Down Expand Up @@ -98,7 +96,7 @@ private function authStep(stdClass $authStep): void
$response = Http::acceptJson()
->post($authStep->url, $authStep->payload);

if($response->status() === 200) {
if ($response->status() === 200) {
$this->authToken = $response->json()[$authStep->token_response_key];
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/FixCollectionImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function handle()

if ($dryRun) {
$col = $collection->first();
if(!$col) {
if (!$col) {
$this->error("Cannot find collection mongo id = {$collectionMongoId}");
} else {
$this->info("Team ID: {$col->id}, Old Logo: {$col->image_link}, New Logo: {$imagePath}");
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/FixImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function handle()
$dryRun = $this->option('dryRun');
$teams = Team::select(["id","team_logo"])->get();
$progressbar = $this->output->createProgressBar(count($teams));
foreach($teams as $team) {
if(is_null($team->team_logo)) {
foreach ($teams as $team) {
if (is_null($team->team_logo)) {
$progressbar->advance();
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/ReindexEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use App\Http\Traits\IndexElastic;
use App\Models\DataProviderColl;
use Illuminate\Console\Command;

use ElasticClientController as ECC;

class ReindexEntities extends Command
Expand Down Expand Up @@ -123,7 +122,7 @@ private function datasets()
$beforeCount = ECC::countDocuments(ECC::ELASTIC_NAME_DATASET);
echo "Before reindexing there were $beforeCount datasets indexed \n";

if($this->fresh) {
if ($this->fresh) {
$nDeleted = ECC::deleteAllDocuments(ECC::ELASTIC_NAME_DATASET);
echo "Deleted $nDeleted documents from the index \n";
}
Expand Down
3 changes: 0 additions & 3 deletions app/Console/Commands/ToolsPostMigrationProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
namespace App\Console\Commands;

use Exception;

use App\Models\Tool;
use App\Models\License;
use App\Models\TypeCategory;
use Illuminate\Console\Command;
use App\Models\ProgrammingLanguage;
use App\Models\ToolHasTypeCategory;


use App\Models\ToolHasProgrammingLanguage;
use App\Http\Traits\IndexElastic;

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateCollectionHasUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function handle()
]);

// collections.authors
foreach($authors as $author) {
foreach ($authors as $author) {
CollectionHasUser::create([
'collection_id' => $collection->id,
'user_id' => $author,
Expand Down
8 changes: 4 additions & 4 deletions app/Console/Commands/UpdateCollectionLinkedEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function handle()

foreach ($this->csvData as $csv) {
$collection = Collection::where('mongo_object_id', $csv['collection_mongo_object_id'])->select('id')->firstOrFail();
if(is_null($collection)) {
if (is_null($collection)) {
//for dev and preprod
//this csv was made from prod snapshot
$progressbar->advance();
Expand All @@ -66,15 +66,15 @@ public function handle()
list($modelClass, $modelHasClass) = $relatedObjectMap[$csv['related_entity']];
$relatedModel = null;

if($csv['related_entity'] !== 'publication') {
if ($csv['related_entity'] !== 'publication') {
$relatedModel = $modelClass::where('mongo_object_id', $csv['related_mongo_object_id'])->first();

}
if(is_null($relatedModel)) {
if (is_null($relatedModel)) {
$relatedModel = $modelClass::where('mongo_id', $csv['related_mongo_id'])->first();
}

if(is_null($relatedModel)) {
if (is_null($relatedModel)) {
//cannot find relationship
$progressbar->advance();
continue;
Expand Down
3 changes: 0 additions & 3 deletions app/Console/Commands/UploadImagesPostMigrationProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
namespace App\Console\Commands;

use Exception;

use App\Models\Upload;

use App\Models\Collection;

use Illuminate\Console\Command;

class UploadImagesPostMigrationProcess extends Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Auditor;
use Exception;

use App\Jobs\SendEmailJob;

use App\Models\Role;
use App\Models\Team;
use App\Models\User;
Expand Down
1 change: 0 additions & 1 deletion app/Exceptions/IntegrationPermissionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Exceptions;

use Exception;

use Illuminate\Http\Response;

class IntegrationPermissionException extends Exception
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/ActivityLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public function edit(EditActivityLog $request, int $id): JsonResponse
public function destroy(DeleteActivityLog $request, int $id): JsonResponse
{
try {
ActivityLog::where('permission_id', $id)->delete();
ActivityLog::where('id', $id)->delete();

return response()->json([
'message' => Config::get('statuscodes.STATUS_OK.message'),
Expand Down
5 changes: 1 addition & 4 deletions app/Http/Controllers/Api/V1/AdminDatasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
use Config;
use Exception;
use Auditor;

use App\Http\Controllers\Controller;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Jobs\TermExtraction;
use App\Jobs\LinkageExtraction;

use App\Models\Dataset;

class AdminDatasetController extends Controller
Expand Down Expand Up @@ -90,7 +87,7 @@ public function triggerTermExtraction(Request $request): JsonResponse
{
try {

if(!Config::get('ted.enabled')) {
if (!Config::get('ted.enabled')) {
throw new Exception("TED not enabled and you're trying to trigger TED");
}

Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/Api/V1/AdminPanelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace App\Http\Controllers\Api\V1;

use App\Jobs\AdminControlTriggerTermExtractionDirector;

use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

class AdminPanelController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function index(Request $request): JsonResponse
$this->checkAccess($input, $teamId, null, 'team');
}
$apps = Application::where('user_id', $jwtUser)->whereNotNull('team_id')->select('team_id')->distinct()->get();
foreach($apps as $app) {
foreach ($apps as $app) {
$this->checkAccess($input, $app->team_id, null, 'team');
}

Expand Down
Loading