Skip to content
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

Feat: Add a single endpoint to fetch community page data #963

Closed
wants to merge 18 commits into from

Conversation

abdullai-t
Copy link
Contributor

@abdullai-t abdullai-t commented Apr 24, 2024

Summary / Highlights

This pull request includes:

  • A new API endpoint designed to retrieve necessary data for rendering a specific page on the community portal. This endpoint will streamline data fetching, ensuring that all relevant information for the page is gathered in a single request, thereby improving efficiency and load times.
  • Updates the community portal's menu items endpoint to include necessary computations for determining active items. Additionally, the appropriate subdomain is now prepended to each menu item link.

Details (Give details about what this PR accomplishes, include any screenshots etc)

Testing Steps (Provide details on how your changes can be tested)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've tested my changes manually.
  • I've added unit tests to my PR.
Transparency (Project board)
  • I've given my PR a meaningful title.
  • I linked this PR to the relevant issue.
  • I moved the linked issue from the "Sprint backlog" to "In progress" when I started this.
  • I moved the linked issue to "QA Verification" now that it is ready to merge.

This commit includes the creation of new functions that will support loading essential initial site data and site menu items. It also includes the addition of extra verification in the handling section to ensure community_id and subdomain are provided. Various utilities to fetch viable menu items and feature flags for a community were added.
This commit removes the redundant 'confirm.sh' script and enhances the handling of environment variables in 'settings.py'. It introduces standardized environment variable checks and configurations in Makefile, and removes the previously hard coded environment variables.
This commit restructures API utilities and associated components, particularly in the context of loading site data. The changes introduce a more streamlined condition branching for page settings with the introduction of function maps, resulting in cleaner and more readable code. It also updates imported models and enhances data loading methods for different types of content like actions, vendors, testimonials, and others. Additionally, some naming changes and paths adjustments are made for accuracy and compatibility.
Page settings data keys in the api utils have been refactored for standardization. Specific keys for homepage, actions, events, vendors, about, testimonials, about us and contact us page settings have all been changed to 'page_data'. This change simplifies data access and highlights the shared structure of these pages.
Modified the eligibility check logic in user_event_nudge module to compare only the dates instead of the full datetime. This ensures that the comparison between last run time and event published time is done only on the basis of date, disregarding the time part.
…uests

Modified several files to improve data fetching, field renaming, and handling of concurrent requests. Updated 'vendor', 'event', 'misc', 'subscriber', 'policy' and 'goal' handlers to adjust field renaming from 'id' to either 'vendor_id', 'event_id', 'subscriber_id', 'policy_id' or 'goal_id'. Optimized 'misc' handler to fetch data from multiple endpoints concurrently using ThreadPoolExecutor. These changes provide more consistent naming across handlers and increases data processing efficiency.
The code modification ensures that duplicate feature flags are eliminated when retrieved. This correction enhances data consistency and prevents any potential confusion or errors due to duplicate flags in the system.
IS_LOCAL has been hardcoded as True to ensure local environment setting. Additionally, the method for env_path selection has been refactored for clarity and simplicity. Now, the path is directly set with corresponding '.env' based on whether IS_PROD, IS_CANARY, or IS_LOCAL is True, defaulting to 'dev.env' otherwise.
The environment condition for LOCAL setup has been updated in settings.py. Instead of setting IS_LOCAL as a boolean constant true, it now compares the DJANGO_ENV with 'local'. This allows more flexibility in managing different environments.
@abdullai-t abdullai-t changed the title mew-optimized-site-link Feat: Add a single endpoint to fetch community page data Apr 24, 2024
src/api/services/misc.py Outdated Show resolved Hide resolved
src/api/store/misc.py Outdated Show resolved Hide resolved
src/api/utils/api_utils.py Outdated Show resolved Hide resolved
@abdullai-t abdullai-t marked this pull request as draft April 24, 2024 15:04
The import statements in the file src/api/store/misc.py have been updated to increase readability. Also, the 'load_essential_initial_site_data' method in src/api/store/misc.py and src/api/services/misc.py has been commented out due to being currently unused. This action is taken as part of code clean up and to improve the maintainability of the codebase.
@abdullai-t abdullai-t marked this pull request as ready for review April 25, 2024 11:01
src/api/constants.py Outdated Show resolved Hide resolved
src/api/handlers/misc.py Outdated Show resolved Hide resolved
src/api/services/misc.py Outdated Show resolved Hide resolved
src/api/store/misc.py Outdated Show resolved Hide resolved
src/api/utils/api_utils.py Outdated Show resolved Hide resolved
src/api/utils/api_utils.py Outdated Show resolved Hide resolved
The commit involves removing extensive site setup utility code from api_utils.py and other miscellaneous functions from misc.py and services/misc.py. This clean-up greatly simplifies the codebase, removing unused and outdated functions related to loading data for various community features and pages.
This change modifies the validator in misc.py to expect 'endpoints', rather than 'data'. This better reflects the actual intent of the function, improving code readability and maintainability.
The PAGE_SETUP_ESSENTIALS constant, which was found in the 'constants.py' file by the navigation path 'src/api', was unused and hence, has been removed. This cleanup contributes to overall code tidiness and efficiency.
This commit includes cookies in the data payload for the post requests in the fetch_data function. It retrieves cookies from the current request and sends them along with post call to ensure consistent user session management.
@abdullai-t abdullai-t linked an issue Apr 25, 2024 that may be closed by this pull request
The community API now fetches and provides the visibility status of the donation page. This extra property for donation_page_settings is included in the same manner as the settings for other pages like testimonial page, vendors page, and others.
abdullai-t added 2 commits May 1, 2024 16:14
Increased code readability by including a TODO comment in misc.py, which highlights the need to revert a change and create a new endpoint for user.portal.menu.load.
@abdullai-t abdullai-t closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a unified endpoint for fetching community data
3 participants