@@ -37,6 +37,7 @@ class OpenAiSettingsService {
3737 'llm_extra_params ' => 'string ' ,
3838 'quota_period ' => 'array ' ,
3939 'quotas ' => 'array ' ,
40+ 'usage_storage_time ' => 'integer ' ,
4041 'translation_provider_enabled ' => 'boolean ' ,
4142 'llm_provider_enabled ' => 'boolean ' ,
4243 't2i_provider_enabled ' => 'boolean ' ,
@@ -310,6 +311,10 @@ public function getQuotas(): array {
310311 return $ quotas ;
311312 }
312313
314+ public function getUsageStorageTime () : int {
315+ return $ this ->appConfig ->getValueInt (Application::APP_ID , 'usage_storage_time ' , Application::DEFAULT_QUOTA_PERIOD , lazy: true );
316+ }
317+
313318 /**
314319 * @return boolean
315320 */
@@ -397,6 +402,7 @@ public function getAdminConfig(): array {
397402 // Updated to get quota period
398403 'quotas ' => $ this ->getQuotas (),
399404 // Get quotas from the config value and return it
405+ 'usage_storage_time ' => $ this ->getUsageStorageTime (),
400406 'translation_provider_enabled ' => $ this ->getTranslationProviderEnabled (),
401407 'llm_provider_enabled ' => $ this ->getLlmProviderEnabled (),
402408 't2i_provider_enabled ' => $ this ->getT2iProviderEnabled (),
@@ -524,6 +530,15 @@ public function setQuotas(array $quotas): void {
524530 $ cache ->clear (Application::QUOTA_RULES_CACHE_PREFIX );
525531 }
526532
533+ /**
534+ * @param int $usageStorageTime
535+ * @return void
536+ */
537+ public function setUsageStorageTime (int $ usageStorageTime ): void {
538+ $ usageStorageTime = max (1 , $ usageStorageTime );
539+ $ this ->appConfig ->setValueInt (Application::APP_ID , 'usage_storage_time ' , $ usageStorageTime , lazy: true );
540+ }
541+
527542 /**
528543 * @param string $apiKey
529544 * @return void
@@ -833,6 +848,9 @@ public function setAdminConfig(array $adminConfig): void {
833848 if (isset ($ adminConfig ['quotas ' ])) {
834849 $ this ->setQuotas ($ adminConfig ['quotas ' ]);
835850 }
851+ if (isset ($ adminConfig ['usage_storage_time ' ])) {
852+ $ this ->setUsageStorageTime (intval ($ adminConfig ['usage_storage_time ' ]));
853+ }
836854 if (isset ($ adminConfig ['use_max_completion_tokens_param ' ])) {
837855 $ this ->setUseMaxCompletionParam ($ adminConfig ['use_max_completion_tokens_param ' ]);
838856 }
0 commit comments