Skip to content

Commit

Permalink
Merge branch 'snipe:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Decode1415 authored Jan 9, 2024
2 parents adbfe72 + 8001ed8 commit d77bef1
Show file tree
Hide file tree
Showing 20 changed files with 1,067 additions and 88 deletions.
7 changes: 5 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"projectName": "snipe-it",
"projectOwner": "snipe",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
"CONTRIBUTORS.md"
],
"imageSize": 110,
"commit": true,
"commitConvention": "angular",
"contributors": [
{
"login": "snipe",
Expand Down Expand Up @@ -3008,4 +3011,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Tests in MySQL

on:
push:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/tests-sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tests in SQLite

on:
push:
branches:
- master
- develop
pull_request:

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "8.1.1"

name: PHP ${{ matrix.php-version }}

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none

- uses: actions/checkout@v4

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Copy .env
run: |
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite_testing
run: php artisan test --parallel
443 changes: 443 additions & 0 deletions CONTRIBUTORS.md

Large diffs are not rendered by default.

64 changes: 2 additions & 62 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function index(Request $request, $audit = null)

// Search custom fields by column name
foreach ($all_custom_fields as $field) {
if ($request->filled($field->db_column_name())) {
if ($request->filled($field->db_column_name()) && $field->db_column_name()) {
$assets->where($field->db_column_name(), '=', $request->input($field->db_column_name()));
}
}
Expand Down
17 changes: 11 additions & 6 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ public function index(Request $request)

$order = $request->input('order') === 'asc' ? 'asc' : 'desc';

// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
$limit = app('api_limit_value');


switch ($request->input('sort')) {
case 'manager':
$users = $users->OrderManager($order);
Expand Down Expand Up @@ -273,7 +268,17 @@ public function index(Request $request)
}

$users = Company::scopeCompanyables($users);



// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
$limit = app('api_limit_value');

\Log::debug('Requested offset: '. $request->input('offset'));
\Log::debug('App offset: '. app('api_offset_value'));
\Log::debug('Actual offset: '. $offset);
\Log::debug('Limit: '. $limit);

$total = $users->count();
$users = $users->skip($offset)->take($limit)->get();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AssetMaintenancesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function transformAssetMaintenance(AssetMaintenance $assetmaintenance)
'name'=> e($assetmaintenance->asset->location->name),

] : null,
'rtd_location' => ($assetmaintenance->asset->defaultLoc) ? [
'rtd_location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->defaultLoc)) ? [
'id' => (int) $assetmaintenance->asset->defaultLoc->id,
'name'=> e($assetmaintenance->asset->defaultLoc->name),
] : null,
Expand Down
1 change: 1 addition & 0 deletions app/Models/AssetMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
protected $searchableRelations = [
'asset' => ['name', 'asset_tag'],
'asset.model' => ['name', 'model_number'],
'asset.supplier' => ['name'],
];

public function getCompanyableParents()
Expand Down
Loading

0 comments on commit d77bef1

Please sign in to comment.