style: fix linting issues met Prettier
This commit is contained in:
parent
aa1a85e64e
commit
2a2881ec30
84 changed files with 846 additions and 1013 deletions
|
@ -1,14 +1,11 @@
|
|||
import {
|
||||
LearningPath,
|
||||
LearningPathResponse
|
||||
} from "../../interfaces/learning-content";
|
||||
import dwengoApiLearningPathProvider from "./dwengo-api-learning-path-provider";
|
||||
import databaseLearningPathProvider from "./database-learning-path-provider";
|
||||
import {EnvVars, getEnvVar} from "../../util/envvars";
|
||||
import {Language} from "../../entities/content/language";
|
||||
import { LearningPath, LearningPathResponse } from '../../interfaces/learning-content';
|
||||
import dwengoApiLearningPathProvider from './dwengo-api-learning-path-provider';
|
||||
import databaseLearningPathProvider from './database-learning-path-provider';
|
||||
import { EnvVars, getEnvVar } from '../../util/envvars';
|
||||
import { Language } from '../../entities/content/language';
|
||||
|
||||
const userContentPrefix = getEnvVar(EnvVars.UserContentPrefix);
|
||||
const allProviders = [dwengoApiLearningPathProvider, databaseLearningPathProvider]
|
||||
const allProviders = [dwengoApiLearningPathProvider, databaseLearningPathProvider];
|
||||
|
||||
/**
|
||||
* Service providing access to data about learning paths from the appropriate data source (database or Dwengo-api)
|
||||
|
@ -18,18 +15,16 @@ const learningPathService = {
|
|||
* Fetch the learning paths with the given hruids from the data source.
|
||||
*/
|
||||
async fetchLearningPaths(hruids: string[], language: Language, source: string): Promise<LearningPathResponse> {
|
||||
const userContentHruids = hruids.filter(hruid => hruid.startsWith(userContentPrefix));
|
||||
const nonUserContentHruids = hruids.filter(hruid => !hruid.startsWith(userContentPrefix));
|
||||
const userContentHruids = hruids.filter((hruid) => hruid.startsWith(userContentPrefix));
|
||||
const nonUserContentHruids = hruids.filter((hruid) => !hruid.startsWith(userContentPrefix));
|
||||
|
||||
const userContentLearningPaths =
|
||||
await databaseLearningPathProvider.fetchLearningPaths(userContentHruids, language, source);
|
||||
const nonUserContentLearningPaths
|
||||
= await dwengoApiLearningPathProvider.fetchLearningPaths(nonUserContentHruids, language, source);
|
||||
const userContentLearningPaths = await databaseLearningPathProvider.fetchLearningPaths(userContentHruids, language, source);
|
||||
const nonUserContentLearningPaths = await dwengoApiLearningPathProvider.fetchLearningPaths(nonUserContentHruids, language, source);
|
||||
|
||||
return {
|
||||
data: (userContentLearningPaths.data || []).concat(nonUserContentLearningPaths.data || []),
|
||||
source: source,
|
||||
success: userContentLearningPaths.success || nonUserContentLearningPaths.success
|
||||
success: userContentLearningPaths.success || nonUserContentLearningPaths.success,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -37,13 +32,9 @@ const learningPathService = {
|
|||
* Search learning paths in the data source using the given search string.
|
||||
*/
|
||||
async searchLearningPaths(query: string, language: Language): Promise<LearningPath[]> {
|
||||
const providerResponses = await Promise.all(
|
||||
allProviders.map(
|
||||
provider => provider.searchLearningPaths(query, language)
|
||||
)
|
||||
);
|
||||
const providerResponses = await Promise.all(allProviders.map((provider) => provider.searchLearningPaths(query, language)));
|
||||
return providerResponses.flat();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default learningPathService;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue