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(air-discount-scheme): Add myflug + add more logs to ads #16655

Merged
merged 4 commits into from
Oct 30, 2024

Conversation

thordurhhh
Copy link
Member

@thordurhhh thordurhhh commented Oct 30, 2024

What

Add myflug + add more logs to ads

Why

  • New airline ✈️
  • More logging 👨‍💻

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for the airline "Mýflug" in the Air Discount Scheme, expanding user options.
    • Enhanced the API with a new key for "Mýflug" to improve service integration.
    • Updated the user interface to include "Mýflug" in airline selection options.
  • Bug Fixes

    • Improved error handling in the National Registry Service for better diagnostics.
  • Documentation

    • Updated README to reflect the addition of "Mýflug" in the API section.
  • Localization

    • Added a new message for code generation failures to improve user feedback.
  • User Interface Improvements

    • Enhanced the display logic for discount codes and user interactions in the AirDiscountOverview component.

Copy link
Contributor

coderabbitai bot commented Oct 30, 2024

Walkthrough

The changes in this pull request include the addition of the airline Myflug to various parts of the Air Discount Scheme application. This addition is reflected in the README, configuration files, and seeder scripts. A new API key for Myflug has been introduced in the backend service setup, and unit tests have been updated to cover this new airline. Error handling has been improved in the NationalRegistryService, and multiple configuration files have been modified to support the new airline's integration across different environments.

Changes

File Path Change Summary
apps/air-discount-scheme/README.md Updated API section to include Myflug in the list of airlines.
apps/air-discount-scheme/backend/infra/air-discount-scheme-backend.ts Added MYFLUG_API_KEY to secrets configuration for the backend service.
apps/air-discount-scheme/backend/seeders/20211108100835-development.js Expanded getRandomFlightLeg function to include myflug in the airline options.
apps/air-discount-scheme/backend/src/app/modules/common/test/unit/auth.guard.spec.ts Added a test case for Myflug API key validation in AuthGuard.
apps/air-discount-scheme/backend/src/app/modules/nationalRegistry/nationalRegistry.service.ts Introduced error handling in getRelations method of NationalRegistryService.
apps/air-discount-scheme/backend/src/environments/environment.ts Updated airlineApiKeys for Myflug in both development and production configurations.
apps/air-discount-scheme/web/screens/Admin/consts.ts Added new entry for Mýflug in airlineOptions.
charts/islandis/values.dev.yaml Added MYFLUG_API_KEY to secrets in air-discount-scheme-backend service; updated ingress configurations.
charts/islandis/values.prod.yaml Added MYFLUG_API_KEY to secrets in air-discount-scheme-backend service; modified health checks and resource allocations.
charts/islandis/values.staging.yaml Added MYFLUG_API_KEY and updated ingress configurations for air-discount-scheme-backend and other services.
libs/air-discount-scheme/consts/src/lib/flight.ts Added myflug entry to the Airlines constant.
libs/portals/admin/air-discount-scheme/src/screens/Overview/consts.ts Added new entry for Mýflug in airlineOptions.
libs/service-portal/air-discount/src/lib/messages.ts Introduced new message codeGenFailed for localization support.
libs/service-portal/air-discount/src/screens/AirDiscountOverview/AirDiscountOverview.tsx Updated logic for displaying discount codes and handling visibility of the copy button.

Suggested labels

automerge

Suggested reviewers

  • thorkellmani
  • eirikurn
  • albinagu

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 918210d and 864d0ea.

📒 Files selected for processing (3)
  • charts/islandis/values.dev.yaml (1 hunks)
  • charts/islandis/values.prod.yaml (1 hunks)
  • charts/islandis/values.staging.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/islandis/values.staging.yaml
🔇 Additional comments (2)
charts/islandis/values.prod.yaml (1)

180-180: LGTM! The Myflug API key secret configuration looks correct.

The secret path /k8s/air-discount-scheme/backend/MYFLUG_API_KEY follows the established pattern used for other airline API keys in the system and is properly configured under the air-discount-scheme-backend service.

Let's verify the consistency of airline API key configurations:

✅ Verification successful

The MYFLUG_API_KEY secret path follows the consistent pattern across all environments

The verification confirms that:

  • All airline API keys (MYFLUG, ERNIR, ICELANDAIR, NORLANDAIR) follow the same path pattern /k8s/air-discount-scheme/backend/*_API_KEY
  • The configuration is consistently applied across all environments (dev, staging, prod)
  • The secret path is also correctly referenced in the infrastructure code
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all airline API key secret paths follow the same pattern
# Expected: All airline API keys should follow the pattern /k8s/air-discount-scheme/backend/*_API_KEY

rg "air-discount-scheme/backend/.*_API_KEY" -A 1 -B 1

Length of output: 3752

charts/islandis/values.dev.yaml (1)

188-188: LGTM! The MYFLUG_API_KEY secret is properly configured.

The addition of the MYFLUG_API_KEY secret follows the established pattern for airline API keys in the air-discount-scheme-backend service configuration. This aligns with the PR objective of adding Myflug as a new airline.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 30, 2024

Datadog Report

All test runs d022565 🔗

4 Total Test Services: 0 Failed, 4 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.05%), 9 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 82 0 29.36s 1 decreased (-0.05%) Link
air-discount-scheme-web 0 0 0 2 0 7.09s 1 no change Link
api 0 0 0 4 0 2.43s 1 no change Link
api-domains-air-discount-scheme 0 0 0 6 0 16.75s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • air-discount-scheme-backend - jest 52.35% (-0.05%) - Details

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.67%. Comparing base (1beceb8) to head (864d0ea).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...dules/nationalRegistry/nationalRegistry.service.ts 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16655      +/-   ##
==========================================
- Coverage   36.67%   36.67%   -0.01%     
==========================================
  Files        6859     6859              
  Lines      142766   142769       +3     
  Branches    40685    40685              
==========================================
- Hits        52364    52361       -3     
- Misses      90402    90408       +6     
Flag Coverage Δ
air-discount-scheme-backend 54.04% <0.00%> (-0.05%) ⬇️
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-catalogue-services 77.85% <ø> (ø)
api-domains-air-discount-scheme 36.93% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.91% <ø> (ø)
api-domains-criminal-record 48.00% <ø> (ø)
api-domains-driving-license 44.48% <ø> (ø)
api-domains-education 31.58% <ø> (ø)
api-domains-health-insurance 34.77% <ø> (ø)
api-domains-mortgage-certificate 34.98% <ø> (ø)
api-domains-payment-schedule 41.16% <ø> (ø)
application-api-files 56.78% <ø> (ø)
application-core 71.17% <ø> (-0.33%) ⬇️
application-system-api 41.33% <ø> (ø)
application-template-api-modules 27.80% <ø> (ø)
application-templates-accident-notification 29.24% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.30% <ø> (ø)
application-templates-driving-license 18.40% <ø> (ø)
application-templates-estate 12.25% <ø> (ø)
application-templates-example-payment 25.20% <ø> (ø)
application-templates-financial-aid 15.47% <ø> (ø)
application-templates-general-petition 23.42% <ø> (ø)
application-templates-inheritance-report 6.51% <ø> (ø)
application-templates-marriage-conditions 15.18% <ø> (ø)
application-templates-mortgage-certificate 43.55% <ø> (ø)
application-templates-parental-leave 29.94% <ø> (ø)
application-types 6.62% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 21.22% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 30.02% <ø> (ø)
auth-react 22.26% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.67% <ø> (ø)
clients-driving-license-book 43.80% <ø> (ø)
clients-financial-statements-inao 49.32% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-middlewares 72.86% <ø> (-0.26%) ⬇️
clients-regulations 42.80% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.49% <ø> (ø)
clients-zendesk 54.61% <ø> (ø)
cms 0.42% <ø> (ø)
cms-translations 39.04% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 5.20% <ø> (ø)
dokobit-signing 63.38% <ø> (ø)
download-service 44.22% <ø> (ø)
email-service 61.13% <ø> (ø)
feature-flags 91.11% <ø> (ø)
file-storage 53.71% <ø> (ø)
financial-aid-backend 51.22% <ø> (ø)
financial-aid-shared 17.81% <ø> (ø)
icelandic-names-registry-backend 53.97% <ø> (ø)
infra-nest-server 48.17% <ø> (ø)
infra-tracing 43.24% <ø> (ø)
island-ui-core 28.86% <ø> (ø)
judicial-system-api 19.52% <ø> (ø)
judicial-system-audit-trail 69.43% <ø> (ø)
judicial-system-backend 55.32% <ø> (ø)
judicial-system-formatters 79.91% <ø> (ø)
judicial-system-message 67.37% <ø> (ø)
judicial-system-message-handler 48.53% <ø> (ø)
judicial-system-scheduler 70.62% <ø> (ø)
judicial-system-types 44.13% <ø> (ø)
judicial-system-web 27.65% <ø> (ø)
license-api 42.53% <ø> (+0.07%) ⬆️
localization 10.15% <ø> (ø)
logging 48.43% <ø> (ø)
message-queue 67.80% <ø> (-0.79%) ⬇️
nest-audit 68.20% <ø> (ø)
nest-aws 61.15% <ø> (ø)
nest-config 78.44% <ø> (ø)
nest-core 43.54% <ø> (ø)
nest-feature-flags 51.52% <ø> (ø)
nest-problem 45.85% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
nova-sms 62.74% <ø> (ø)
portals-admin-regulations-admin 1.84% <ø> (ø)
portals-core 16.01% <ø> (ø)
reference-backend 49.79% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 51.89% <ø> (ø)
services-auth-delegation-api 57.45% <ø> (ø)
services-auth-ids-api 51.44% <ø> (ø)
services-auth-personal-representative 45.07% <ø> (+0.02%) ⬆️
services-auth-personal-representative-public 41.26% <ø> (ø)
services-auth-public-api 48.95% <ø> (ø)
services-documents 60.58% <ø> (ø)
services-endorsements-api 53.59% <ø> (ø)
services-sessions 65.34% <ø> (ø)
services-university-gateway 49.37% <ø> (-0.09%) ⬇️
services-user-notification 46.93% <ø> (ø)
services-user-profile 61.84% <ø> (+0.07%) ⬆️
shared-components 27.51% <ø> (ø)
shared-form-fields 31.22% <ø> (ø)
shared-mocking 64.62% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.18% <ø> (ø)
testing-e2e 66.66% <ø> (ø)
web 1.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...unt-scheme/backend/src/environments/environment.ts 77.77% <ø> (ø)
...ps/air-discount-scheme/web/screens/Admin/consts.ts 0.00% <ø> (ø)
libs/air-discount-scheme/consts/src/lib/flight.ts 100.00% <ø> (ø)
...dules/nationalRegistry/nationalRegistry.service.ts 18.64% <0.00%> (-1.00%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0bb793...864d0ea. Read the comment docs.

@thordurhhh thordurhhh marked this pull request as ready for review October 30, 2024 17:15
@thordurhhh thordurhhh requested review from a team as code owners October 30, 2024 17:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (7)
libs/air-discount-scheme/consts/src/lib/flight.ts (1)

Line range hint 1-19: Consider adding TypeScript enum or union type for Airlines.

To improve type safety and autocompletion, consider defining a TypeScript type for the airlines.

Add this type definition above the constants:

export type Airline = 'ernir' | 'icelandair' | 'norlandair' | 'myflug';

// Then update the Airlines const to use the type
export const Airlines: Record<Airline, Airline> = {
  ernir: 'ernir',
  icelandair: 'icelandair',
  norlandair: 'norlandair',
  myflug: 'myflug',
}
apps/air-discount-scheme/backend/src/app/modules/common/test/unit/auth.guard.spec.ts (1)

45-55: LGTM! Consider enhancing test description consistency.

The test case for Myflug follows the established pattern and correctly validates the API key integration. The implementation is clean and well-structured.

For consistency with other test descriptions, consider using the airline's official name "Mýflug" in the test description:

-  it('Api key should work for Myflug', async () => {
+  it('Api key should work for Mýflug', async () => {
apps/air-discount-scheme/backend/infra/air-discount-scheme-backend.ts (1)

Line range hint 1-67: Consider enhancing observability configuration.

Since one of the PR objectives is to enhance logging, consider adding structured logging configuration to the service setup. This could include:

  • Log aggregation configuration
  • Log level configuration per environment
  • Metrics endpoint configuration for monitoring

Would you like assistance in implementing these observability enhancements?

libs/service-portal/air-discount/src/lib/messages.ts (1)

58-61: LGTM! Consider adding JSDoc comment for better documentation.

The new error message follows the established pattern and integrates well with the existing messages. The ID and default message are consistent with the naming conventions.

Consider adding a JSDoc comment to document the usage context:

+/**
+ * Message displayed when the discount code generation fails.
+ * Used in the AirDiscountOverview component for error feedback.
+ */
 codeGenFailed: {
   id: 'sp.air-discount:code-generation-fail',
   defaultMessage: 'Ekki tókst að útbúa kóða',
 },
apps/air-discount-scheme/README.md (1)

24-24: Consider documenting the API key configuration.

Based on the changes mentioned in the summary, there's a new MYFLUG_API_KEY configuration. Consider adding this to the development setup section to ensure completeness of the documentation.

Here's a suggested addition to the Development section:

 1. Fetch the environment secrets:
 
 ```bash
 yarn get-secrets air-discount-scheme-api
 yarn get-secrets air-discount-scheme-backend
 yarn get-secrets air-discount-scheme-web
+
+# Required environment variables include:
+# - MYFLUG_API_KEY: API key for Myflug airline integration

</blockquote></details>
<details>
<summary>apps/air-discount-scheme/backend/src/app/modules/nationalRegistry/nationalRegistry.service.ts (1)</summary><blockquote>

Line range hint `1-359`: **Consider architectural improvements for maintainability and security.**

A few suggestions to improve the overall service architecture:
1. Move `TEST_USERS` array to a separate test data file
2. Add input validation for `authUser` parameter
3. Consider implementing caching for `getUser` results since the injected `cacheManager` is unused

Would you like me to provide specific implementation details for any of these suggestions?

</blockquote></details>
<details>
<summary>libs/service-portal/air-discount/src/screens/AirDiscountOverview/AirDiscountOverview.tsx (1)</summary><blockquote>

`194-194`: **Consider adding error logging for failed code generation.**

The fallback text provides good user feedback, but given the PR's objective to enhance logging, consider adding error logging when code generation fails.


```diff
   secondaryText={
     item.user.fund?.credit === 0
       ? undefined
       : item.discountCode
       ? item.discountCode
-       : formatMessage(m.codeGenFailed)
+       : (() => {
+           console.error('ADS: Failed to generate discount code for user', {
+             nationalId: item.nationalId,
+             userName: item.user.name
+           });
+           return formatMessage(m.codeGenFailed);
+         })()
   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0947e07 and 918210d.

📒 Files selected for processing (14)
  • apps/air-discount-scheme/README.md (1 hunks)
  • apps/air-discount-scheme/backend/infra/air-discount-scheme-backend.ts (1 hunks)
  • apps/air-discount-scheme/backend/seeders/20211108100835-development.js (1 hunks)
  • apps/air-discount-scheme/backend/src/app/modules/common/test/unit/auth.guard.spec.ts (1 hunks)
  • apps/air-discount-scheme/backend/src/app/modules/nationalRegistry/nationalRegistry.service.ts (1 hunks)
  • apps/air-discount-scheme/backend/src/environments/environment.ts (2 hunks)
  • apps/air-discount-scheme/web/screens/Admin/consts.ts (1 hunks)
  • charts/islandis/values.dev.yaml (1 hunks)
  • charts/islandis/values.prod.yaml (1 hunks)
  • charts/islandis/values.staging.yaml (1 hunks)
  • libs/air-discount-scheme/consts/src/lib/flight.ts (1 hunks)
  • libs/portals/admin/air-discount-scheme/src/screens/Overview/consts.ts (1 hunks)
  • libs/service-portal/air-discount/src/lib/messages.ts (1 hunks)
  • libs/service-portal/air-discount/src/screens/AirDiscountOverview/AirDiscountOverview.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
apps/air-discount-scheme/README.md (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/backend/infra/air-discount-scheme-backend.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/backend/seeders/20211108100835-development.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/backend/src/app/modules/common/test/unit/auth.guard.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/backend/src/app/modules/nationalRegistry/nationalRegistry.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/backend/src/environments/environment.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/air-discount-scheme/web/screens/Admin/consts.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/air-discount-scheme/consts/src/lib/flight.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/admin/air-discount-scheme/src/screens/Overview/consts.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/air-discount/src/lib/messages.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/air-discount/src/screens/AirDiscountOverview/AirDiscountOverview.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (12)
libs/air-discount-scheme/consts/src/lib/flight.ts (1)

18-18: LGTM! Verify usage of the new airline constant.

The addition follows the existing pattern and naming convention.

Let's verify the usage of this new airline constant:

✅ Verification successful

The new airline constant is properly integrated across the codebase

The verification shows that the new myflug airline constant is:

  • Correctly referenced in admin UI components with proper labeling as 'Mýflug'
  • Properly configured in backend environment with API key setup
  • Included in authentication tests
  • Used consistently through ValueOf type references

No switch statements or hardcoded airline strings were found that would need updating.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any potential issues with the new airline constant usage

# Test 1: Check if there are any hardcoded airline strings that should use the constant
rg -i "myflug|mýflug" --type ts --type tsx

# Test 2: Look for switch statements or if-else chains that might need updating
ast-grep --pattern 'switch ($expr) { $$$ case $airline: $$$ }'

Length of output: 137


Script:

#!/bin/bash
# Let's try a different approach to verify the usage

# Check for any references to myflug in TypeScript files
rg -i "myflug|mýflug" --type ts

# Look for switch statements in TypeScript files that handle airlines
rg "switch.*airlines?" --type ts -B 1 -A 5

# Check for any type definitions or interfaces that might need to be updated
rg "type.*Airlines|interface.*Airlines" --type ts -A 3

# Look for any test files that might need updating for the new airline
fd "test|spec" -e ts -x rg -i "airlines?" {} -A 2

Length of output: 5544

apps/air-discount-scheme/web/screens/Admin/consts.ts (1)

31-34: LGTM! Verify Airlines enum includes myflug.

The addition of Mýflug airline follows the existing pattern and maintains alphabetical order in the options list.

Let's verify the Airlines enum includes the myflug value:

libs/portals/admin/air-discount-scheme/src/screens/Overview/consts.ts (2)

31-34: LGTM! The new airline entry follows established patterns.

The addition of Mýflug maintains consistency with other airline entries and follows proper alphabetical ordering.


31-34: Verify the Airlines enum definition.

Let's ensure that the Airlines.myflug value is properly defined in the imported constants.

✅ Verification successful

Airlines.myflug is properly defined in the constants

The verification confirms that Airlines.myflug is correctly defined in libs/air-discount-scheme/consts/src/lib/flight.ts with the value 'myflug'.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Airlines enum includes the myflug definition

# Test: Search for myflug in the air-discount-scheme constants
# Expect: Definition of myflug in the Airlines enum
ast-grep --pattern 'export const Airlines = {
  $$$
  myflug: $_,
  $$$
}'

Length of output: 516

apps/air-discount-scheme/backend/src/environments/environment.ts (1)

12-12: LGTM! Development configuration for Myflug follows established patterns.

The addition of Myflug to the development configuration maintains consistency with other airlines and properly utilizes the Airlines enum.

apps/air-discount-scheme/backend/seeders/20211108100835-development.js (1)

36-37: Verify test coverage with the new airline addition.

The addition of 'myflug' to the airlines array is correct and aligns with the PR objectives. However, since this seeder is used for generating test data, we should verify that existing tests aren't making assumptions about specific airlines.

✅ Verification successful

Let me check the Airlines enum or constant definition to understand how airlines are handled in the codebase.


The seeder changes are safe and aligned with the codebase

The addition of 'myflug' to the seeder is correct as 'myflug' is already properly defined in the Airlines constant (libs/air-discount-scheme/consts/src/lib/flight.ts). The test files use the Airlines enum for type safety rather than hardcoded strings, which means they will automatically support the new airline. The only direct airline string references in tests are for API authorization tokens, which are independent of the seeder's random airline selection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests that might have hardcoded airline expectations
rg -g "*.test.*" -g "*.spec.*" "ernir|norlandair|icelandair" apps/air-discount-scheme/

Length of output: 4341


Script:

#!/bin/bash
# Search for Airlines enum or constant definition
ast-grep --pattern 'enum Airlines {
  $$$
}'

# Also search for any other airline-related constant definitions
rg -g "*.ts" "const.*Airlines.*=.*{" -A 5

Length of output: 196


Script:

#!/bin/bash
# Search for Airlines type/enum/const definition with fixed regex
rg -g "*.ts" "Airlines.*=.*" -B 2 -A 2

# Also search for airline-related imports and types
rg -g "*.ts" "import.*Airlines.*from"

Length of output: 3378


Script:

#!/bin/bash
# Let's check the full content of the Airlines constant
cat libs/air-discount-scheme/consts/src/lib/flight.ts

Length of output: 422

apps/air-discount-scheme/backend/infra/air-discount-scheme-backend.ts (1)

10-10: LGTM! API key configuration follows established patterns.

The addition of MYFLUG_API_KEY follows the consistent pattern used for other airline API keys and maintains alphabetical ordering.

Let's verify the secret configuration across environments:

✅ Verification successful

API key configuration verified and follows established patterns

The MYFLUG_API_KEY configuration is correctly implemented:

  • Follows the same path pattern /k8s/air-discount-scheme/backend/ as other airline API keys (ICELANDAIR, ERNIR, NORLANDAIR)
  • Maintains consistent naming convention with other airline API keys
  • Is grouped together with other airline-related API keys in the configuration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that MYFLUG_API_KEY is properly configured across all environments

# Test: Check if the secret is configured in values files for all environments
echo "Checking secret configuration in values files..."
rg "MYFLUG_API_KEY" "charts/islandis/values*.yaml"

# Test: Ensure the secret path follows the established pattern
echo "Verifying secret path pattern..."
rg "/k8s/air-discount-scheme/backend/[A-Z_]+_API_KEY" "apps/air-discount-scheme/backend/infra/*.ts"

Length of output: 487


Script:

#!/bin/bash
# Let's try a different approach using fd to find the relevant files first

# Find all yaml files that might contain values
echo "Looking for values files..."
fd -e yaml values

# Find the infrastructure files
echo "Looking for infrastructure files..."
fd -e ts infra

# Once we find the files, let's check the API key patterns
echo "Checking API key patterns in found files..."
fd -e ts infra -x rg -l "API_KEY"

# Check for other airline API keys to compare patterns
echo "Checking other airline API keys..."
fd -e ts -x rg "/k8s.*API_KEY"

Length of output: 3041

apps/air-discount-scheme/README.md (1)

24-24: LGTM: Addition of Myflug to supported airlines list.

The change accurately reflects the addition of Myflug as a new supported airline.

libs/service-portal/air-discount/src/screens/AirDiscountOverview/AirDiscountOverview.tsx (1)

201-201: LGTM: Button visibility logic is well-implemented.

The condition correctly combines both credit check and code availability, preventing interaction when no valid code is available.

charts/islandis/values.staging.yaml (1)

188-188: LGTM: Myflug API key secret configuration added correctly

The addition of MYFLUG_API_KEY secret follows the established pattern used for other airline API keys (like ERNIR_API_KEY, ICELANDAIR_API_KEY, etc.) in the air-discount-scheme-backend service. This change aligns with the PR objective of adding Myflug as a new airline.

charts/islandis/values.prod.yaml (1)

180-180: LGTM: New Myflug API key secret follows established pattern

The addition of the MYFLUG_API_KEY secret follows the same path pattern as other airline API keys in the air-discount-scheme-backend service.

✅ Verification successful

✅ API key path follows consistent pattern across environments

The MYFLUG_API_KEY secret path /k8s/air-discount-scheme/backend/MYFLUG_API_KEY follows the exact same pattern as other airline API keys (Icelandair, Ernir, Norlandair) across all environments (dev, staging, prod) and infrastructure code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the secret path follows the same pattern as other airline API keys
rg "air-discount-scheme/backend/.*_API_KEY" -A 1 -B 1

Length of output: 3752

charts/islandis/values.dev.yaml (1)

188-188: LGTM! The Myflug API key secret is properly configured.

The new MYFLUG_API_KEY secret follows the established pattern for airline API keys in the air-discount-scheme-backend service. The secret path is consistent with other airline configurations.

Let's verify the configuration consistency across environments:

✅ Verification successful

Configuration verified: MYFLUG_API_KEY is consistently defined across all environments

The verification confirms that the MYFLUG_API_KEY secret is properly configured with the same path /k8s/air-discount-scheme/backend/MYFLUG_API_KEY across all environment value files:

  • values.dev.yaml
  • values.staging.yaml
  • values.prod.yaml
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that Myflug API key is consistently configured across environments
# Test: Check if MYFLUG_API_KEY exists in all environment value files with the same path pattern

echo "Checking MYFLUG_API_KEY configuration across environments..."
rg "MYFLUG_API_KEY.*'/k8s/air-discount-scheme/backend/MYFLUG_API_KEY'" charts/islandis/values.*.yaml

Length of output: 621

Copy link
Member

@brynjarorng brynjarorng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Tryggvig Tryggvig left a comment

Choose a reason for hiding this comment

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

🤡

@thordurhhh thordurhhh added the automerge Merge this PR as soon as all checks pass label Oct 30, 2024
@kodiakhq kodiakhq bot merged commit ed88ed8 into main Oct 30, 2024
266 checks passed
@kodiakhq kodiakhq bot deleted the air-discount-scheme/myflug-and-logging branch October 30, 2024 23:06
thordurhhh added a commit that referenced this pull request Oct 31, 2024
* Add myflug

* No code fallback. Improve logging when relation endpoint fails

* Seq revert

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants