diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-20 10:17:03 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-20 10:18:05 +0100 |
commit | 15825ef18d3b2bb74f4e613496cf3e2921a87389 (patch) | |
tree | d68b590baa98b090c212a117317c21059e064725 | |
parent | 5471449f998eec270b184e6080e6f9853e5d722a (diff) | |
download | PeerTube-15825ef18d3b2bb74f4e613496cf3e2921a87389.tar.gz PeerTube-15825ef18d3b2bb74f4e613496cf3e2921a87389.tar.zst PeerTube-15825ef18d3b2bb74f4e613496cf3e2921a87389.zip |
Fix default trending algorithm in admin config
-rw-r--r-- | client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html | 3 | ||||
-rw-r--r-- | client/src/app/+videos/video-list/videos-list-common-page.component.ts | 3 | ||||
-rw-r--r-- | client/src/app/app.module.ts | 16 | ||||
-rw-r--r-- | client/src/app/core/routing/redirect.service.ts | 11 | ||||
-rw-r--r-- | client/src/app/core/server/server.service.ts | 2 | ||||
-rw-r--r-- | config/default.yaml | 10 | ||||
-rw-r--r-- | config/production.yaml.example | 10 |
7 files changed, 30 insertions, 25 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index 22ae0852c..2a9f9d69d 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html | |||
@@ -44,9 +44,6 @@ | |||
44 | 44 | ||
45 | <div class="peertube-select-container"> | 45 | <div class="peertube-select-container"> |
46 | <select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control"> | 46 | <select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control"> |
47 | <option i18n value="publishedAt">Recently added videos</option> | ||
48 | <option i18n value="originallyPublishedAt">Original publication date</option> | ||
49 | <option i18n value="name">Name</option> | ||
50 | <option i18n value="hot">Hot videos</option> | 47 | <option i18n value="hot">Hot videos</option> |
51 | <option i18n value="most-viewed">Recent views</option> | 48 | <option i18n value="most-viewed">Recent views</option> |
52 | <option i18n value="most-liked">Most liked videos</option> | 49 | <option i18n value="most-liked">Most liked videos</option> |
diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.ts index bafe30fd7..c8fa8ef30 100644 --- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts +++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts | |||
@@ -177,9 +177,6 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disable | |||
177 | case 'best': | 177 | case 'best': |
178 | return '-hot' | 178 | return '-hot' |
179 | 179 | ||
180 | case 'name': | ||
181 | return 'name' | ||
182 | |||
183 | default: | 180 | default: |
184 | return '-' + algorithm as VideoSortField | 181 | return '-' + algorithm as VideoSortField |
185 | } | 182 | } |
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index bb20c2d83..7e4fac730 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -8,7 +8,7 @@ import { ServiceWorkerModule } from '@angular/service-worker' | |||
8 | import localeOc from '@app/helpers/locales/oc' | 8 | import localeOc from '@app/helpers/locales/oc' |
9 | import { AppRoutingModule } from './app-routing.module' | 9 | import { AppRoutingModule } from './app-routing.module' |
10 | import { AppComponent } from './app.component' | 10 | import { AppComponent } from './app.component' |
11 | import { CoreModule, PluginService, ServerService } from './core' | 11 | import { CoreModule, PluginService, RedirectService, ServerService } from './core' |
12 | import { EmptyComponent } from './empty.component' | 12 | import { EmptyComponent } from './empty.component' |
13 | import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header' | 13 | import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header' |
14 | import { HighlightPipe } from './header/highlight.pipe' | 14 | import { HighlightPipe } from './header/highlight.pipe' |
@@ -28,13 +28,17 @@ import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settings | |||
28 | 28 | ||
29 | registerLocaleData(localeOc, 'oc') | 29 | registerLocaleData(localeOc, 'oc') |
30 | 30 | ||
31 | export function loadConfigFactory (server: ServerService, pluginService: PluginService) { | 31 | export function loadConfigFactory (server: ServerService, pluginService: PluginService, redirectService: RedirectService) { |
32 | const initializeServices = () => { | ||
33 | redirectService.init() | ||
34 | pluginService.initializePlugins() | ||
35 | } | ||
36 | |||
32 | return () => { | 37 | return () => { |
33 | const result = server.loadHTMLConfig() | 38 | const result = server.loadHTMLConfig() |
39 | if (result) return result.pipe(tap(() => initializeServices())) | ||
34 | 40 | ||
35 | if (result) return result.pipe(tap(() => pluginService.initializePlugins())) | 41 | initializeServices() |
36 | |||
37 | return pluginService.initializePlugins() | ||
38 | } | 42 | } |
39 | } | 43 | } |
40 | 44 | ||
@@ -84,7 +88,7 @@ export function loadConfigFactory (server: ServerService, pluginService: PluginS | |||
84 | { | 88 | { |
85 | provide: APP_INITIALIZER, | 89 | provide: APP_INITIALIZER, |
86 | useFactory: loadConfigFactory, | 90 | useFactory: loadConfigFactory, |
87 | deps: [ ServerService, PluginService ], | 91 | deps: [ ServerService, PluginService, RedirectService ], |
88 | multi: true | 92 | multi: true |
89 | } | 93 | } |
90 | ] | 94 | ] |
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index e239c6210..1120e6165 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts | |||
@@ -31,12 +31,15 @@ export class RedirectService { | |||
31 | private serverService: ServerService, | 31 | private serverService: ServerService, |
32 | private storage: SessionStorageService | 32 | private storage: SessionStorageService |
33 | ) { | 33 | ) { |
34 | // The config is first loaded from the cache so try to get the default route | 34 | |
35 | } | ||
36 | |||
37 | init () { | ||
35 | const config = this.serverService.getHTMLConfig() | 38 | const config = this.serverService.getHTMLConfig() |
36 | if (config?.instance?.defaultClientRoute) { | 39 | if (config.instance.defaultClientRoute) { |
37 | this.defaultRoute = config.instance.defaultClientRoute | 40 | this.defaultRoute = config.instance.defaultClientRoute |
38 | } | 41 | } |
39 | if (config?.trending?.videos?.algorithms?.default) { | 42 | if (config.trending.videos.algorithms.default) { |
40 | this.defaultTrendingAlgorithm = config.trending.videos.algorithms.default | 43 | this.defaultTrendingAlgorithm = config.trending.videos.algorithms.default |
41 | } | 44 | } |
42 | 45 | ||
@@ -47,7 +50,7 @@ export class RedirectService { | |||
47 | 50 | ||
48 | // Track previous url | 51 | // Track previous url |
49 | this.currentUrl = this.router.url | 52 | this.currentUrl = this.router.url |
50 | router.events.subscribe(event => { | 53 | this.router.events.subscribe(event => { |
51 | if (event instanceof NavigationEnd || event instanceof NavigationCancel) { | 54 | if (event instanceof NavigationEnd || event instanceof NavigationCancel) { |
52 | if ([ '/401', '/404' ].includes(event.url)) return | 55 | if ([ '/401', '/404' ].includes(event.url)) return |
53 | 56 | ||
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 9db455cb8..0829d87d5 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -40,7 +40,7 @@ export class ServerService { | |||
40 | 40 | ||
41 | loadHTMLConfig () { | 41 | loadHTMLConfig () { |
42 | try { | 42 | try { |
43 | return this.loadHTMLConfigLocally() | 43 | this.loadHTMLConfigLocally() |
44 | } catch (err) { | 44 | } catch (err) { |
45 | // Expected in dev mode since we can't inject the config in the HTML | 45 | // Expected in dev mode since we can't inject the config in the HTML |
46 | if (environment.production !== false) { | 46 | if (environment.production !== false) { |
diff --git a/config/default.yaml b/config/default.yaml index 37059e9e0..bb4a823fa 100644 --- a/config/default.yaml +++ b/config/default.yaml | |||
@@ -236,12 +236,14 @@ open_telemetry: | |||
236 | 236 | ||
237 | trending: | 237 | trending: |
238 | videos: | 238 | videos: |
239 | interval_days: 7 # Compute trending videos for the last x days | 239 | interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm |
240 | |||
240 | algorithms: | 241 | algorithms: |
241 | enabled: | 242 | enabled: |
242 | - 'hot' # adaptation of Reddit's 'Hot' algorithm | 243 | - 'hot' # Adaptation of Reddit's 'Hot' algorithm |
243 | - 'most-viewed' # default, used initially by PeerTube as the trending page | 244 | - 'most-viewed' # Number of views in the last x days |
244 | - 'most-liked' | 245 | - 'most-liked' # Global views since the upload of the video |
246 | |||
245 | default: 'most-viewed' | 247 | default: 'most-viewed' |
246 | 248 | ||
247 | # Cache remote videos on your server, to help other instances to broadcast the video | 249 | # Cache remote videos on your server, to help other instances to broadcast the video |
diff --git a/config/production.yaml.example b/config/production.yaml.example index 906fb7e1f..f1ebf9095 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example | |||
@@ -234,12 +234,14 @@ open_telemetry: | |||
234 | 234 | ||
235 | trending: | 235 | trending: |
236 | videos: | 236 | videos: |
237 | interval_days: 7 # Compute trending videos for the last x days | 237 | interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm |
238 | |||
238 | algorithms: | 239 | algorithms: |
239 | enabled: | 240 | enabled: |
240 | - 'hot' # adaptation of Reddit's 'Hot' algorithm | 241 | - 'hot' # Adaptation of Reddit's 'Hot' algorithm |
241 | - 'most-viewed' # default, used initially by PeerTube as the trending page | 242 | - 'most-viewed' # Number of views in the last x days |
242 | - 'most-liked' | 243 | - 'most-liked' # Global views since the upload of the video |
244 | |||
243 | default: 'most-viewed' | 245 | default: 'most-viewed' |
244 | 246 | ||
245 | # Cache remote videos on your server, to help other instances to broadcast the video | 247 | # Cache remote videos on your server, to help other instances to broadcast the video |