refactor(server): job repository (#1382)

* refactor(server): job repository

* refactor: job repository

* chore: generate open-api

* fix: job panel

* Remove incorrect subtitle

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen
2023-01-21 23:13:36 -05:00
committed by GitHub
parent f4c90426a5
commit 4cfac47674
34 changed files with 418 additions and 1124 deletions

View File

@@ -53,7 +53,6 @@ doc/JobCommand.md
doc/JobCommandDto.md
doc/JobCounts.md
doc/JobId.md
doc/JobStatusResponseDto.md
doc/LoginCredentialDto.md
doc/LoginResponseDto.md
doc/LogoutResponseDto.md
@@ -162,7 +161,6 @@ lib/model/job_command.dart
lib/model/job_command_dto.dart
lib/model/job_counts.dart
lib/model/job_id.dart
lib/model/job_status_response_dto.dart
lib/model/login_credential_dto.dart
lib/model/login_response_dto.dart
lib/model/logout_response_dto.dart
@@ -250,7 +248,6 @@ test/job_command_dto_test.dart
test/job_command_test.dart
test/job_counts_test.dart
test/job_id_test.dart
test/job_status_response_dto_test.dart
test/login_credential_dto_test.dart
test/login_response_dto_test.dart
test/logout_response_dto_test.dart

View File

@@ -106,7 +106,6 @@ Class | Method | HTTP request | Description
*DeviceInfoApi* | [**updateDeviceInfo**](doc//DeviceInfoApi.md#updatedeviceinfo) | **PATCH** /device-info |
*DeviceInfoApi* | [**upsertDeviceInfo**](doc//DeviceInfoApi.md#upsertdeviceinfo) | **PUT** /device-info |
*JobApi* | [**getAllJobsStatus**](doc//JobApi.md#getalljobsstatus) | **GET** /jobs |
*JobApi* | [**getJobStatus**](doc//JobApi.md#getjobstatus) | **GET** /jobs/{jobId} |
*JobApi* | [**sendJobCommand**](doc//JobApi.md#sendjobcommand) | **PUT** /jobs/{jobId} |
*OAuthApi* | [**callback**](doc//OAuthApi.md#callback) | **POST** /oauth/callback |
*OAuthApi* | [**generateConfig**](doc//OAuthApi.md#generateconfig) | **POST** /oauth/config |
@@ -189,7 +188,6 @@ Class | Method | HTTP request | Description
- [JobCommandDto](doc//JobCommandDto.md)
- [JobCounts](doc//JobCounts.md)
- [JobId](doc//JobId.md)
- [JobStatusResponseDto](doc//JobStatusResponseDto.md)
- [LoginCredentialDto](doc//LoginCredentialDto.md)
- [LoginResponseDto](doc//LoginResponseDto.md)
- [LogoutResponseDto](doc//LogoutResponseDto.md)

View File

@@ -8,16 +8,11 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**thumbnailGenerationQueueCount** | [**JobCounts**](JobCounts.md) | |
**metadataExtractionQueueCount** | [**JobCounts**](JobCounts.md) | |
**videoConversionQueueCount** | [**JobCounts**](JobCounts.md) | |
**machineLearningQueueCount** | [**JobCounts**](JobCounts.md) | |
**storageMigrationQueueCount** | [**JobCounts**](JobCounts.md) | |
**isThumbnailGenerationActive** | **bool** | |
**isMetadataExtractionActive** | **bool** | |
**isVideoConversionActive** | **bool** | |
**isMachineLearningActive** | **bool** | |
**isStorageMigrationActive** | **bool** | |
**thumbnailGeneration** | [**JobCounts**](JobCounts.md) | |
**metadataExtraction** | [**JobCounts**](JobCounts.md) | |
**videoConversion** | [**JobCounts**](JobCounts.md) | |
**machineLearning** | [**JobCounts**](JobCounts.md) | |
**storageTemplateMigration** | [**JobCounts**](JobCounts.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -10,7 +10,6 @@ All URIs are relative to */api*
Method | HTTP request | Description
------------- | ------------- | -------------
[**getAllJobsStatus**](JobApi.md#getalljobsstatus) | **GET** /jobs |
[**getJobStatus**](JobApi.md#getjobstatus) | **GET** /jobs/{jobId} |
[**sendJobCommand**](JobApi.md#sendjobcommand) | **PUT** /jobs/{jobId} |
@@ -59,55 +58,6 @@ This endpoint does not need any parameter.
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **getJobStatus**
> JobStatusResponseDto getJobStatus(jobId)
### Example
```dart
import 'package:openapi/api.dart';
// TODO Configure HTTP Bearer authorization: bearer
// Case 1. Use String Token
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');
// Case 2. Use Function which generate token.
// String yourTokenGeneratorFunction() { ... }
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
final api_instance = JobApi();
final jobId = ; // JobId |
try {
final result = api_instance.getJobStatus(jobId);
print(result);
} catch (e) {
print('Exception when calling JobApi->getJobStatus: $e\n');
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**jobId** | [**JobId**](.md)| |
### Return type
[**JobStatusResponseDto**](JobStatusResponseDto.md)
### Authorization
[bearer](../README.md#bearer)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **sendJobCommand**
> num sendJobCommand(jobId, jobCommandDto)

View File

@@ -1,16 +0,0 @@
# openapi.model.JobStatusResponseDto
## Load the model package
```dart
import 'package:openapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**isActive** | **bool** | |
**queueCount** | [**Object**](.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -84,7 +84,6 @@ part 'model/job_command.dart';
part 'model/job_command_dto.dart';
part 'model/job_counts.dart';
part 'model/job_id.dart';
part 'model/job_status_response_dto.dart';
part 'model/login_credential_dto.dart';
part 'model/login_response_dto.dart';
part 'model/logout_response_dto.dart';

View File

@@ -60,59 +60,6 @@ class JobApi {
return null;
}
///
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters:
///
/// * [JobId] jobId (required):
Future<Response> getJobStatusWithHttpInfo(JobId jobId,) async {
// ignore: prefer_const_declarations
final path = r'/jobs/{jobId}'
.replaceAll('{jobId}', jobId.toString());
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
///
///
/// Parameters:
///
/// * [JobId] jobId (required):
Future<JobStatusResponseDto?> getJobStatus(JobId jobId,) async {
final response = await getJobStatusWithHttpInfo(jobId,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'JobStatusResponseDto',) as JobStatusResponseDto;
}
return null;
}
///
///
/// Note: This method returns the HTTP [Response].

View File

@@ -280,8 +280,6 @@ class ApiClient {
return JobCounts.fromJson(value);
case 'JobId':
return JobIdTypeTransformer().decode(value);
case 'JobStatusResponseDto':
return JobStatusResponseDto.fromJson(value);
case 'LoginCredentialDto':
return LoginCredentialDto.fromJson(value);
case 'LoginResponseDto':

View File

@@ -13,80 +13,50 @@ part of openapi.api;
class AllJobStatusResponseDto {
/// Returns a new [AllJobStatusResponseDto] instance.
AllJobStatusResponseDto({
required this.thumbnailGenerationQueueCount,
required this.metadataExtractionQueueCount,
required this.videoConversionQueueCount,
required this.machineLearningQueueCount,
required this.storageMigrationQueueCount,
required this.isThumbnailGenerationActive,
required this.isMetadataExtractionActive,
required this.isVideoConversionActive,
required this.isMachineLearningActive,
required this.isStorageMigrationActive,
required this.thumbnailGeneration,
required this.metadataExtraction,
required this.videoConversion,
required this.machineLearning,
required this.storageTemplateMigration,
});
JobCounts thumbnailGenerationQueueCount;
JobCounts thumbnailGeneration;
JobCounts metadataExtractionQueueCount;
JobCounts metadataExtraction;
JobCounts videoConversionQueueCount;
JobCounts videoConversion;
JobCounts machineLearningQueueCount;
JobCounts machineLearning;
JobCounts storageMigrationQueueCount;
bool isThumbnailGenerationActive;
bool isMetadataExtractionActive;
bool isVideoConversionActive;
bool isMachineLearningActive;
bool isStorageMigrationActive;
JobCounts storageTemplateMigration;
@override
bool operator ==(Object other) => identical(this, other) || other is AllJobStatusResponseDto &&
other.thumbnailGenerationQueueCount == thumbnailGenerationQueueCount &&
other.metadataExtractionQueueCount == metadataExtractionQueueCount &&
other.videoConversionQueueCount == videoConversionQueueCount &&
other.machineLearningQueueCount == machineLearningQueueCount &&
other.storageMigrationQueueCount == storageMigrationQueueCount &&
other.isThumbnailGenerationActive == isThumbnailGenerationActive &&
other.isMetadataExtractionActive == isMetadataExtractionActive &&
other.isVideoConversionActive == isVideoConversionActive &&
other.isMachineLearningActive == isMachineLearningActive &&
other.isStorageMigrationActive == isStorageMigrationActive;
other.thumbnailGeneration == thumbnailGeneration &&
other.metadataExtraction == metadataExtraction &&
other.videoConversion == videoConversion &&
other.machineLearning == machineLearning &&
other.storageTemplateMigration == storageTemplateMigration;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(thumbnailGenerationQueueCount.hashCode) +
(metadataExtractionQueueCount.hashCode) +
(videoConversionQueueCount.hashCode) +
(machineLearningQueueCount.hashCode) +
(storageMigrationQueueCount.hashCode) +
(isThumbnailGenerationActive.hashCode) +
(isMetadataExtractionActive.hashCode) +
(isVideoConversionActive.hashCode) +
(isMachineLearningActive.hashCode) +
(isStorageMigrationActive.hashCode);
(thumbnailGeneration.hashCode) +
(metadataExtraction.hashCode) +
(videoConversion.hashCode) +
(machineLearning.hashCode) +
(storageTemplateMigration.hashCode);
@override
String toString() => 'AllJobStatusResponseDto[thumbnailGenerationQueueCount=$thumbnailGenerationQueueCount, metadataExtractionQueueCount=$metadataExtractionQueueCount, videoConversionQueueCount=$videoConversionQueueCount, machineLearningQueueCount=$machineLearningQueueCount, storageMigrationQueueCount=$storageMigrationQueueCount, isThumbnailGenerationActive=$isThumbnailGenerationActive, isMetadataExtractionActive=$isMetadataExtractionActive, isVideoConversionActive=$isVideoConversionActive, isMachineLearningActive=$isMachineLearningActive, isStorageMigrationActive=$isStorageMigrationActive]';
String toString() => 'AllJobStatusResponseDto[thumbnailGeneration=$thumbnailGeneration, metadataExtraction=$metadataExtraction, videoConversion=$videoConversion, machineLearning=$machineLearning, storageTemplateMigration=$storageTemplateMigration]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'thumbnailGenerationQueueCount'] = this.thumbnailGenerationQueueCount;
json[r'metadataExtractionQueueCount'] = this.metadataExtractionQueueCount;
json[r'videoConversionQueueCount'] = this.videoConversionQueueCount;
json[r'machineLearningQueueCount'] = this.machineLearningQueueCount;
json[r'storageMigrationQueueCount'] = this.storageMigrationQueueCount;
json[r'isThumbnailGenerationActive'] = this.isThumbnailGenerationActive;
json[r'isMetadataExtractionActive'] = this.isMetadataExtractionActive;
json[r'isVideoConversionActive'] = this.isVideoConversionActive;
json[r'isMachineLearningActive'] = this.isMachineLearningActive;
json[r'isStorageMigrationActive'] = this.isStorageMigrationActive;
json[r'thumbnail-generation'] = this.thumbnailGeneration;
json[r'metadata-extraction'] = this.metadataExtraction;
json[r'video-conversion'] = this.videoConversion;
json[r'machine-learning'] = this.machineLearning;
json[r'storage-template-migration'] = this.storageTemplateMigration;
return json;
}
@@ -109,16 +79,11 @@ class AllJobStatusResponseDto {
}());
return AllJobStatusResponseDto(
thumbnailGenerationQueueCount: JobCounts.fromJson(json[r'thumbnailGenerationQueueCount'])!,
metadataExtractionQueueCount: JobCounts.fromJson(json[r'metadataExtractionQueueCount'])!,
videoConversionQueueCount: JobCounts.fromJson(json[r'videoConversionQueueCount'])!,
machineLearningQueueCount: JobCounts.fromJson(json[r'machineLearningQueueCount'])!,
storageMigrationQueueCount: JobCounts.fromJson(json[r'storageMigrationQueueCount'])!,
isThumbnailGenerationActive: mapValueOfType<bool>(json, r'isThumbnailGenerationActive')!,
isMetadataExtractionActive: mapValueOfType<bool>(json, r'isMetadataExtractionActive')!,
isVideoConversionActive: mapValueOfType<bool>(json, r'isVideoConversionActive')!,
isMachineLearningActive: mapValueOfType<bool>(json, r'isMachineLearningActive')!,
isStorageMigrationActive: mapValueOfType<bool>(json, r'isStorageMigrationActive')!,
thumbnailGeneration: JobCounts.fromJson(json[r'thumbnail-generation'])!,
metadataExtraction: JobCounts.fromJson(json[r'metadata-extraction'])!,
videoConversion: JobCounts.fromJson(json[r'video-conversion'])!,
machineLearning: JobCounts.fromJson(json[r'machine-learning'])!,
storageTemplateMigration: JobCounts.fromJson(json[r'storage-template-migration'])!,
);
}
return null;
@@ -168,16 +133,11 @@ class AllJobStatusResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'thumbnailGenerationQueueCount',
'metadataExtractionQueueCount',
'videoConversionQueueCount',
'machineLearningQueueCount',
'storageMigrationQueueCount',
'isThumbnailGenerationActive',
'isMetadataExtractionActive',
'isVideoConversionActive',
'isMachineLearningActive',
'isStorageMigrationActive',
'thumbnail-generation',
'metadata-extraction',
'video-conversion',
'machine-learning',
'storage-template-migration',
};
}

View File

@@ -1,119 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class JobStatusResponseDto {
/// Returns a new [JobStatusResponseDto] instance.
JobStatusResponseDto({
required this.isActive,
required this.queueCount,
});
bool isActive;
Object queueCount;
@override
bool operator ==(Object other) => identical(this, other) || other is JobStatusResponseDto &&
other.isActive == isActive &&
other.queueCount == queueCount;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(isActive.hashCode) +
(queueCount.hashCode);
@override
String toString() => 'JobStatusResponseDto[isActive=$isActive, queueCount=$queueCount]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'isActive'] = this.isActive;
json[r'queueCount'] = this.queueCount;
return json;
}
/// Returns a new [JobStatusResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static JobStatusResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "JobStatusResponseDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "JobStatusResponseDto[$key]" has a null value in JSON.');
});
return true;
}());
return JobStatusResponseDto(
isActive: mapValueOfType<bool>(json, r'isActive')!,
queueCount: mapValueOfType<Object>(json, r'queueCount')!,
);
}
return null;
}
static List<JobStatusResponseDto>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <JobStatusResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = JobStatusResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, JobStatusResponseDto> mapFromJson(dynamic json) {
final map = <String, JobStatusResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = JobStatusResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of JobStatusResponseDto-objects as value to a dart map
static Map<String, List<JobStatusResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<JobStatusResponseDto>>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = JobStatusResponseDto.listFromJson(entry.value, growable: growable,);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'isActive',
'queueCount',
};
}

View File

@@ -16,53 +16,28 @@ void main() {
// final instance = AllJobStatusResponseDto();
group('test AllJobStatusResponseDto', () {
// JobCounts thumbnailGenerationQueueCount
test('to test the property `thumbnailGenerationQueueCount`', () async {
// JobCounts thumbnailGeneration
test('to test the property `thumbnailGeneration`', () async {
// TODO
});
// JobCounts metadataExtractionQueueCount
test('to test the property `metadataExtractionQueueCount`', () async {
// JobCounts metadataExtraction
test('to test the property `metadataExtraction`', () async {
// TODO
});
// JobCounts videoConversionQueueCount
test('to test the property `videoConversionQueueCount`', () async {
// JobCounts videoConversion
test('to test the property `videoConversion`', () async {
// TODO
});
// JobCounts machineLearningQueueCount
test('to test the property `machineLearningQueueCount`', () async {
// JobCounts machineLearning
test('to test the property `machineLearning`', () async {
// TODO
});
// JobCounts storageMigrationQueueCount
test('to test the property `storageMigrationQueueCount`', () async {
// TODO
});
// bool isThumbnailGenerationActive
test('to test the property `isThumbnailGenerationActive`', () async {
// TODO
});
// bool isMetadataExtractionActive
test('to test the property `isMetadataExtractionActive`', () async {
// TODO
});
// bool isVideoConversionActive
test('to test the property `isVideoConversionActive`', () async {
// TODO
});
// bool isMachineLearningActive
test('to test the property `isMachineLearningActive`', () async {
// TODO
});
// bool isStorageMigrationActive
test('to test the property `isStorageMigrationActive`', () async {
// JobCounts storageTemplateMigration
test('to test the property `storageTemplateMigration`', () async {
// TODO
});

View File

@@ -24,13 +24,6 @@ void main() {
// TODO
});
//
//
//Future<JobStatusResponseDto> getJobStatus(JobId jobId) async
test('test getJobStatus', () async {
// TODO
});
//
//
//Future<num> sendJobCommand(JobId jobId, JobCommandDto jobCommandDto) async

View File

@@ -1,32 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
import 'package:openapi/api.dart';
import 'package:test/test.dart';
// tests for JobStatusResponseDto
void main() {
// final instance = JobStatusResponseDto();
group('test JobStatusResponseDto', () {
// bool isActive
test('to test the property `isActive`', () async {
// TODO
});
// Object queueCount
test('to test the property `queueCount`', () async {
// TODO
});
});
}