-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-[x] New Tab Popup Close Fix, Flow Change Bulk Publish
-[x] WIP Bulk Publish Progress -[x] Added top_level_error in validator status check response -[x] Added Critical Error Check -[x] Select All Fixing -[x] Disabled Checkbox for Critical Errored Activitities -[x] Added skipping critical error activities on publish -[x] Fix not writing in db -[x] Disabled Select All -[x] Uncommented Test -[x] Added Open in new Tab Text -[x] Added Screenshot for completeness -[x] Minimize While Bulk Publish Fixes -[x] Added Title Ellipsis When Longer Title -[x] Truncated Title -[x] 0 Value Test -[x] Fix 0 Issue Showing -[x] Support Button When Open New Tab Position Issue -[x] Text Changes -[x] Step shown for only error -[x] Text Changes, Removed Open in New Tab if no Error -[x] Refresh when Close last step -[x] ORG Type Capitalized for Superadmin -[x] Not showing warning on error type warning, Text changes -[x] Removed Refresh Toast Message -[x] Added Back Refresh Toast -[x] Message Changes -[x] Removed Warning For Advisory -[x] Advisory Fixing -[x] Text Changes
- Loading branch information
Yash Maharjan
committed
Jan 28, 2025
1 parent
987d171
commit 02bdfb9
Showing
29 changed files
with
2,318 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Helpers; | ||
|
||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Facades\Cache; | ||
|
||
class BulkPublishCacheHelper | ||
{ | ||
/** | ||
* Default cache structure when there is no cache found for the organization. | ||
* | ||
* @var array | ||
*/ | ||
private const EMPTY_CACHE = [ | ||
'status' => false, | ||
'activity_ids' => [], | ||
]; | ||
|
||
/** | ||
* The cache key format used to store bulk publish data for an organization. | ||
* | ||
* @var string | ||
*/ | ||
private const CACHE_KEY = 'ongoing_bulk_publish_%s'; | ||
|
||
/** | ||
* Get the cache key for the organization. | ||
* | ||
* @param int $orgId | ||
* @return string | ||
*/ | ||
private static function getCacheKey(int $orgId): string | ||
{ | ||
return sprintf(self::CACHE_KEY, (string) $orgId); | ||
} | ||
|
||
/** | ||
* Retrieve the bulk publish cache for the given organization. | ||
* | ||
* @param int $orgId | ||
* @return array The bulk publish cache or empty cache if none found | ||
*/ | ||
public static function getOrganisationBulkPublishCache(int $orgId): array | ||
{ | ||
return Cache::get(self::getCacheKey($orgId), self::EMPTY_CACHE); | ||
} | ||
|
||
/** | ||
* Check if there is an ongoing bulk publish for a given organization. | ||
* | ||
* @param int $orgId | ||
* @return bool True if there is an ongoing bulk publish, false otherwise | ||
*/ | ||
public static function hasOngoingBulkPublish(int $orgId): bool | ||
{ | ||
return Arr::get(self::getOrganisationBulkPublishCache($orgId), 'status', false); | ||
} | ||
|
||
public static function getActivityIdsInCache(int $orgId): array | ||
{ | ||
return Arr::get(self::getOrganisationBulkPublishCache($orgId), 'activity_ids', []); | ||
} | ||
|
||
public static function activitiesHaveChanged(int $orgId): bool | ||
{ | ||
return count(self::getActivityIdsInCache($orgId)) > 0; | ||
} | ||
|
||
/** | ||
* Set the initial bulk publish cache for a given organization. | ||
* | ||
* @param int $orgId | ||
* @return void | ||
*/ | ||
public static function setInitialBulkPublishCache(int $orgId): void | ||
{ | ||
if (!self::hasOngoingBulkPublish($orgId)) { | ||
$cacheValue = self::EMPTY_CACHE; | ||
$cacheValue['status'] = true; | ||
|
||
self::updateCache($orgId, $cacheValue); | ||
} | ||
} | ||
|
||
/** | ||
* Append an activity ID in the bulk publish cache for a given organization. | ||
* | ||
* @param int $orgId | ||
* @param int $activityId | ||
* @return void | ||
*/ | ||
public static function appendActivityIdInBulkPublishCache(int $orgId, int $activityId): void | ||
{ | ||
$cacheValue = self::getOrganisationBulkPublishCache($orgId); | ||
|
||
if (!in_array($activityId, $cacheValue['activity_ids'], true)) { | ||
$cacheValue['activity_ids'][] = $activityId; | ||
|
||
self::updateCache($orgId, $cacheValue); | ||
} | ||
} | ||
|
||
/** | ||
* Clear the cache for a given organization. | ||
* This removes the bulk publish data from the cache. | ||
* | ||
* @param int $orgId | ||
* @return void | ||
*/ | ||
public static function clearBulkPublishCache(int $orgId): void | ||
{ | ||
Cache::forget(self::getCacheKey($orgId)); | ||
} | ||
|
||
/** | ||
* Helper method to update the cache for the given organization. | ||
* | ||
* @param int $orgId | ||
* @param array $cacheValue | ||
* @return void | ||
*/ | ||
private static function updateCache(int $orgId, array $cacheValue): void | ||
{ | ||
Cache::put(self::getCacheKey($orgId), $cacheValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.