Skip to content

Commit

Permalink
Merge pull request #888 from wmde/release/2024-03-28
Browse files Browse the repository at this point in the history
Release Mismatch Finder to Production
  • Loading branch information
hasanakg authored Mar 28, 2024
2 parents 6f1385e + a1d3224 commit bf6cdf7
Show file tree
Hide file tree
Showing 100 changed files with 8,625 additions and 4,729 deletions.
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/essential',
'plugin:vue/vue3-strongly-recommended',
],
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@v3.8.1
uses: actions/setup-node@v4.0.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@v3.8.1
uses: actions/setup-node@v4.0.1
with:
node-version: '18.x'
- name: Install composer dependencies
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ jobs:
- uses: actions/checkout@v4

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

- name: Install Dependencies
run: npm ci

- name: Run ESLint
- name: Run ESlint and Stylelint
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@v3
uses: actions/checkout@v4
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@v3.8.1
uses: actions/setup-node@v4.0.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@v3.8.1
uses: actions/setup-node@v4.0.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@v3
uses: actions/upload-artifact@v4
with:
name: logs
path: ./storage/logs

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

- name: Upload Console Logs
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: console
path: tests/Browser/console
9 changes: 9 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rules": {
"selector-class-pattern": [null]
},
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-recommended-vue/scss"
]
}
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,
'item_ids' => $requestedItemIds,
'itemIds' => $requestedItemIds,
// Use wikidata to fetch labels for found entity ids
'labels' => $wikidata->getLabels($entityIds, $lang),
'formatted_values' => $formattedTimeValues,
'formattedValues' => $formattedTimeValues,
],
// only add 'results' prop if mismatches have been found
$mismatches->isNotEmpty() ? [ 'results' => $mismatches->groupBy('item_id') ] : []
Expand Down
83 changes: 75 additions & 8 deletions app/Jobs/ImportCSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,58 @@ public function handle(CSVImportReader $reader)
$filepath = Storage::disk('local')
->path('mismatch-files/' . $this->meta->filename);

DB::transaction(function () use ($reader, $filepath) {
$reader->lines($filepath)->each(function ($mismatchLine) {
$mismatch = Mismatch::make($mismatchLine);
if ($mismatch->type == null) {
$mismatch->type = 'statement';
$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);
});
}
$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 @@ -64,7 +106,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 @@ -78,4 +120,29 @@ 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: 0 additions & 8 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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 @@ -49,13 +48,6 @@ 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: 9 additions & 3 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.10",
"kevinrob/guzzle-cache-middleware": "^4.1.2",
"inertiajs/inertia-laravel": "^0.6.11",
"kevinrob/guzzle-cache-middleware": "^5.1.0",
"laravel/framework": "^8.83.26",
"laravel/sanctum": "^2.15.1",
"laravel/socialite": "^5.9",
"laravel/tinker": "^2.8",
"taavi/laravel-socialite-mediawiki": "^1.4"
"taavi/laravel-socialite-mediawiki": "dev-main"
},
"require-dev": {
"facade/ignition": "^2.17.7",
Expand Down Expand Up @@ -72,6 +72,12 @@
"php": "7.3"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wmde/laravel-socialite-mediawiki"
}
],
"minimum-stability": "dev",
"prefer-stable": true
}
Loading

0 comments on commit bf6cdf7

Please sign in to comment.