Skip to content

[Refactor] Availability Page to Fetch Data from Backend #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 12, 2024
Merged

Conversation

Aloento
Copy link
Member

@Aloento Aloento commented Dec 1, 2024

Summary of the Pull Request

This PR focuses on improving the functionality, performance, and maintainability of the application by transitioning the Availability page's data management from real-time computation to fetching data from the backend. The changes include:

Key Changes

  1. Refactor IStatusContext and EmptyDB

    • Removed unused Histories to simplify and clean up the data model.
  2. Enhanced Subject Retrieval

    • Improved subject retrieval logic with a promise fallback mechanism for better reliability.
    • Removed unused SLA helper functions to streamline code.
  3. New Custom Hook: useAvailability

    • Introduced a new hook, useAvailability, to manage service availability data effectively.
  4. Updated CategoryGroup Component

    • Replaced legacy service retrieval logic with the newly introduced useAvailability hook for consistency and better data flow.

@Aloento Aloento requested a review from SebastianGode December 1, 2024 11:25
@Aloento Aloento self-assigned this Dec 1, 2024
@@ -77,7 +77,7 @@ export function useAvailability(category: Models.ICategory, topic: string) {
const rs = DB.RegionService.find(x => x.Id === service.id);

if (!rs) {
log.warn("Service not found.", service);
log.info("Service not found.", service);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be a warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's a hidden service by design if not found.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

@Aloento Aloento requested review from SebastianGode and sgmv December 2, 2024 14:06
interface ServiceAvaEntity {
id: number
name: string
availability: AvaliaEntity[]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AvailEntity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

region: string
}

interface AvaliaEntity {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AvailEntity here also

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Percentages: Array(6).fill(100)
})));

const url = process.env.SD_BACKEND_URL;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better to extract this type of const from method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After compiling, it will be statically replaced with a const string and inline.
const url = "https://...";
so, it's fine here, XD

@Aloento Aloento added the gate Merge PR label Dec 12, 2024
@otc-zuul otc-zuul bot merged commit dc44c0a into main Dec 12, 2024
8 checks passed
@otc-zuul otc-zuul bot deleted the feat_ava branch December 12, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gate Merge PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants