Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Revert "Release Mismatch Finder to Production" #889

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = {
extends: [
'eslint:recommended',
'@vue/typescript/recommended',
'plugin:vue/vue3-strongly-recommended',
'plugin:vue/essential',
],
parser: 'vue-eslint-parser',
rules: {
'max-len': [ 'error', 120 ],
'no-multiple-empty-lines' : ['error', { 'max': 1 }],
'vue/multi-word-component-names' : [ 'off' ]
},
},
};
2 changes: 1 addition & 1 deletion .github/workflows/deploy-app-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'
- name: Install composer dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'
- name: Install composer dependencies
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ jobs:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'

- name: Install Dependencies
run: npm ci

- name: Run ESlint and Stylelint
- name: Run ESLint
run: npm run lint

- name: Run i18 Validation
run: npm run i18n:validate

2 changes: 1 addition & 1 deletion .github/workflows/schedule-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
ref: development
- name: Branch out Release
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
php-version: '7.3'

- name: Setup Node.js
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'

Expand Down Expand Up @@ -110,21 +110,21 @@ jobs:

- name: Upload Laravel Logs
if: failure()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: logs
path: ./storage/logs

- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: screenshots
path: tests/Browser/screenshots

- name: Upload Console Logs
if: failure()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: console
path: tests/Browser/console
9 changes: 0 additions & 9 deletions .stylelintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions app/Http/Controllers/ResultsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public function index(MismatchGetRequest $request, WikibaseAPIClient $wikidata):
$props = array_merge(
[
'user' => $user,
'itemIds' => $requestedItemIds,
'item_ids' => $requestedItemIds,
// Use wikidata to fetch labels for found entity ids
'labels' => $wikidata->getLabels($entityIds, $lang),
'formattedValues' => $formattedTimeValues,
'formatted_values' => $formattedTimeValues,
],
// only add 'results' prop if mismatches have been found
$mismatches->isNotEmpty() ? [ 'results' => $mismatches->groupBy('item_id') ] : []
Expand Down
83 changes: 8 additions & 75 deletions app/Jobs/ImportCSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,58 +46,16 @@ public function handle(CSVImportReader $reader)
$filepath = Storage::disk('local')
->path('mismatch-files/' . $this->meta->filename);

$mismatch_attrs = (new Mismatch())->getFillable();

DB::transaction(function () use ($reader, $filepath, $mismatch_attrs) {
$new_mismatches = [];
$where_clauses = [];

$mismatches_per_upload_user = DB::table('mismatches')
->select($mismatch_attrs)
->join('import_meta', 'mismatches.import_id', '=', 'import_meta.id')
->where('import_meta.user_id', '=', $this->meta->user->id);

$reader->lines($filepath)->each(function ($mismatchLine) use (
&$new_mismatches,
&$where_clauses
) {

$new_mismatch = $this->createMismatch($mismatchLine);
$new_mismatches[] = $new_mismatch;
$where_clause = [['review_status', '!=', 'pending']];
foreach ($new_mismatch->getAttributes() as $key => $attribute) {
if ($key == 'review_status') {
continue;
}
$where_clause[] = [$key, $attribute];
}
$where_clauses[] = $where_clause;
});

$mismatches_per_upload_user->where(function ($query) use ($where_clauses) {
foreach ($where_clauses as $where_clause) {
$query->orWhere(function ($query) use ($where_clause) {
$query->where($where_clause);
});
DB::transaction(function () use ($reader, $filepath) {
$reader->lines($filepath)->each(function ($mismatchLine) {
$mismatch = Mismatch::make($mismatchLine);
if ($mismatch->type == null) {
$mismatch->type = 'statement';
}
$mismatch->importMeta()->associate($this->meta);
$mismatch->save();
});

$existing_mismatches = $mismatches_per_upload_user->get();

foreach ($new_mismatches as $new_mismatch) {
if ($existing_mismatches->doesntContain(function ($value) use ($new_mismatch) {
$metaAttrs = $new_mismatch->getAttributes();
foreach ($metaAttrs as $attrKey => $attr) {
if ($attrKey != 'review_status' && $value->{$attrKey} != $attr) {
return false;
}
}
return true;
})) {
$this->saveMismatch($new_mismatch);
}
}

$this->meta->status = 'completed';
$this->meta->save();
});
Expand All @@ -106,7 +64,7 @@ public function handle(CSVImportReader $reader)
/**
* Handle a job failure.
*
* @param \Throwable $exception
* @param \Throwable $exception
* @return void
*/
public function failed(Throwable $exception)
Expand All @@ -120,29 +78,4 @@ public function failed(Throwable $exception)
$this->meta->status = 'failed';
$this->meta->save();
}


private function createMismatch($mismatch_data)
{
$new_mismatch = Mismatch::make($mismatch_data);

if ($new_mismatch->type == null) {
$new_mismatch->type = 'statement';
}

return $new_mismatch;
}

/**
* Save mismatch to database
*
* @param \Mismatch $new_mismatch
* @return void
*/
private function saveMismatch($new_mismatch)
{
// if review_status == pending -> save
$new_mismatch->importMeta()->associate($this->meta);
$new_mismatch->save();
}
}
8 changes: 8 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\App;

class RouteServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -48,6 +49,13 @@ public function boot()
->namespace($this->namespace)
->group(base_path('routes/auth.php'));

if (App::environment('local')) {
Route::prefix('dev')
->middleware('web')
->namespace($this->namespace)
->group(base_path('routes/dev.php'));
}

Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Expand Down
12 changes: 3 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.2.0",
"guzzlehttp/guzzle": "^7.8",
"inertiajs/inertia-laravel": "^0.6.11",
"kevinrob/guzzle-cache-middleware": "^5.1.0",
"inertiajs/inertia-laravel": "^0.6.10",
"kevinrob/guzzle-cache-middleware": "^4.1.2",
"laravel/framework": "^8.83.26",
"laravel/sanctum": "^2.15.1",
"laravel/socialite": "^5.9",
"laravel/tinker": "^2.8",
"taavi/laravel-socialite-mediawiki": "dev-main"
"taavi/laravel-socialite-mediawiki": "^1.4"
},
"require-dev": {
"facade/ignition": "^2.17.7",
Expand Down Expand Up @@ -72,12 +72,6 @@
"php": "7.3"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wmde/laravel-socialite-mediawiki"
}
],
"minimum-stability": "dev",
"prefer-stable": true
}
Loading
Loading