File tree Expand file tree Collapse file tree 8 files changed +59
-57
lines changed
presenter/express/api/v1/routes
getDiscoveryItemsForHomepage Expand file tree Collapse file tree 8 files changed +59
-57
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ apiVersion: v1
2
2
description : A Helm chart for kube-ts-server
3
3
name : kube-ts-server
4
4
version : 1.0.0
5
- appVersion : 1.4.32
5
+ appVersion : 1.4.37
6
6
home : https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-server
7
7
icon : https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
8
8
sources :
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ replicaCount: 2
6
6
7
7
image :
8
8
repository : kubejs/kube-ts-server
9
- tag : 1.4.32
9
+ tag : 1.4.37
10
10
pullPolicy : Always
11
11
containerPort : 3000
12
12
Original file line number Diff line number Diff line change @@ -6,8 +6,15 @@ import catchErrors from '../../../../utils/errors/catchErrors';
6
6
7
7
const getDiscoveryItems = ( config : Config ) =>
8
8
catchErrors ( config , async ( req , res ) => {
9
-
10
- const response = await config . service . getDiscoveryItems ( { } ) ;
9
+ const type = req . query . type ;
10
+
11
+ let response ;
12
+
13
+ switch ( type ) {
14
+ case 'homepage' :
15
+ default :
16
+ response = await config . service . getDiscoveryItemsForHomepage ( { } ) ;
17
+ }
11
18
12
19
sendResponse ( {
13
20
body : toSnake ( response ) ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Object {
18
18
" version" : " /version" ,
19
19
},
20
20
" courses" : " /api/v1/courses" ,
21
+ " discovery_items" : " /api/v1/discovery-items" ,
21
22
" enrolments" : " /api/v1/enrolments" ,
22
23
" permissions" : " /api/v1/permissions" ,
23
24
" roles" : " /api/v1/roles" ,
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ const describeApi = (config: Config) =>
25
25
version,
26
26
} ,
27
27
courses : '/api/v1/courses' ,
28
+ discoveryItems : '/api/v1/discovery-items' ,
28
29
enrolments : '/api/v1/enrolments' ,
29
30
permissions : '/api/v1/permissions' ,
30
31
roles : '/api/v1/roles' ,
Original file line number Diff line number Diff line change 1
1
import migrationsServiceFactory from '@js-migrations/core/dist/factory' ;
2
2
import FactoryConfig from './FactoryConfig' ;
3
3
import authFactory from './functions/auth/factory' ;
4
- import getDiscoveryItems from './functions/getDiscoveryItems ' ;
4
+ import getDiscoveryItemsForHomepage from './functions/getDiscoveryItemsForHomepage ' ;
5
5
import hasPermission from './functions/hasPermission' ;
6
6
import assignRolePermission from './functions/roles/assignRolePermission' ;
7
7
import revokeRolePermission from './functions/roles/revokeRolePermission' ;
@@ -16,7 +16,7 @@ export default (config: FactoryConfig) => ({
16
16
closeDbConnection : config . repo . closeDbConnection ,
17
17
courses : config . repo . courses ,
18
18
enrolments : config . repo . enrolments ,
19
- getDiscoveryItems : getDiscoveryItems ( config ) ,
19
+ getDiscoveryItemsForHomepage : getDiscoveryItemsForHomepage ( config ) ,
20
20
hasPermission : hasPermission ( config ) ,
21
21
migrations : migrationsServiceFactory ( {
22
22
repo : config . repo . migrations ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import _pluck from 'ramda/src/pluck' ;
2
+ import Course from '../../../types/items/Course' ;
3
+ import Config from '../../FactoryConfig' ;
4
+
5
+ // tslint:disable-next-line:no-empty-interface
6
+ export interface Options { }
7
+
8
+ // tslint:disable-next-line:arrow-return-shorthand
9
+ export default ( { repo } : Config ) => async ( _options : Options ) => {
10
+ const { items : categories } = await repo . categories . getItems ( {
11
+ pagination : {
12
+ limit : 10000 ,
13
+ } ,
14
+ } ) ;
15
+
16
+ const { items : courses } = await repo . courses . getItems ( {
17
+ pagination : {
18
+ limit : 10000 ,
19
+ } ,
20
+ } ) ;
21
+
22
+ const { items : users } = await repo . users . getItems ( {
23
+ pagination : {
24
+ limit : 10000 ,
25
+ } ,
26
+ } ) ;
27
+
28
+ const enhancedCourses = courses . map ( ( course : Course ) => ( {
29
+ ...course ,
30
+ user : users . filter ( user => user . id === course . userId ) ,
31
+ } ) ) ;
32
+
33
+ return {
34
+ bestSellers : {
35
+ // TODO: in the future basing on number of enrolments choose the most popular one
36
+ categories,
37
+ courses : enhancedCourses ,
38
+ } ,
39
+ mostViewed : {
40
+ // TODO: in the future choose the most viewed ones
41
+ courses : enhancedCourses ,
42
+ } ,
43
+ } ;
44
+ } ;
You can’t perform that action at this time.
0 commit comments