8000 Yuqiang/parents page dynamic corrily price by smallst · Pull Request #7735 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Yuqiang/parents page dynamic corrily price #7735

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 5 commits into from
Sep 29, 2024

Conversation

smallst
Copy link
Contributor
@smallst smallst commented Sep 27, 2024

fix ENG-1213

i cannot test it since i'm not in corrily price 😂 but I think I follow the subscribe modal logic. anyone can test it ?

Summary by CodeRabbit

  • New Features

    • Simplified routing by removing the redundant 'parents-v2' entry.
    • Updated routing for /parents to directly import the parents-v2 version of the PageParents component.
    • Added new pricing placeholders for self-paced courses in the localization module.
    • Enhanced FeaturesGrid component to dynamically display subscription-based pricing.
  • Bug Fixes

    • Removed outdated experiment logic related to the parents page.

Copy link
Contributor
coderabbitai bot commented Sep 27, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve modifications to the routing configuration, component imports, localization entries, and the User model. Specifically, the 'parents-v2' route has been removed, and the /parents path now directly imports the parents-v2 version of the PageParents component. Additionally, new localization entries for pricing have been added, and a method related to experiment values in the User model has been removed. These changes aim to streamline routing, enhance component functionality, and support dynamic pricing.

Changes

Files Change Summary
app/core/Router.js, app/core/vueRouter.js Removed 'parents-v2' route; updated /parents route to directly import parents-v2 component.
app/locale/en.js Added new localization entries for self-paced course pricing.
app/models/User.js Removed getParentsPageExperimentValue() method; minor syntax adjustment in startHomeControlExperiment.
app/views/landing-pages/parents-v2/FeaturesGrid.vue Added computed property price and method loadProducts to enhance pricing display based on subscriptions.

Assessment against linked issues

Objective Addressed Explanation
Update /parents page to show dynamic Corrily price for self-paced annual subscription (ENG-1213)

Possibly related PRs

Suggested reviewers

  • nwinter

Poem

🐰 In the meadow, changes bloom,
A route removed, to clear the room.
With pricing bright, the future's clear,
Dynamic tales for all to hear.
Hops of joy, let’s celebrate,
For every change, we elevate! 🌼


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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: 5

🧹 Outside diff range and nitpick comments (1)
app/models/User.js (1)

1116-1120: LGTM! Consider adding a comment for clarity.

The addition of the forcedValue parameter to startHomeControlExperiment is a good improvement, allowing for more flexible control of the experiment value. This change aligns well with the PR objectives related to dynamic pricing on the parents page.

Consider adding a brief comment explaining the purpose of the forcedValue parameter for future maintainers. For example:

 startHomeControlExperiment (forcedValue) {
+  // forcedValue: Optional parameter to manually set the experiment value for testing or specific scenarios
   return this.getFilteredExperimentValue({
     experimentName: 'home-page-filtered-control-experiment',
     forcedValue,
   })
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7b1c586 and d1f907c.

📒 Files selected for processing (5)
  • app/core/Router.js (0 hunks)
  • app/core/vueRouter.js (1 hunks)
  • app/locale/en.js (1 hunks)
  • app/models/User.js (1 hunks)
  • app/views/landing-pages/parents-v2/FeaturesGrid.vue (2 hunks)
💤 Files not reviewed due to no reviewable changes (1)
  • app/core/Router.js
🔇 Additional comments (10)
app/core/vueRouter.js (1)

52-53: Verify alignment with Corrily price testing objective

The component import for the /parents route has been updated to always use the 'parents-v2' version, removing the previous A/B testing logic. While this simplifies the code, please clarify:

  1. How does this change support the PR objective of displaying a dynamic Corrily price for the self-paced annual subscription?
  2. Is the 'parents-v2' component configured to handle the Corrily price experimentation mentioned in the linked issue ENG-1213?
  3. Have we ensured that removing the A/B testing logic doesn't impact our ability to conduct the planned price experimentation in the US market?

To confirm the implementation of Corrily pricing in the new component, please run:

The simplification of the import logic is a positive change for code maintainability.

app/models/User.js (1)

Line range hint 1-1120: Confirm the removal of getParentsPageExperimentValue

The removal of the getParentsPageExperimentValue method, as mentioned in the AI-generated summary, appears to be in line with the changes made to startHomeControlExperiment. This suggests a shift in how experiments are managed for the parents page, which aligns with the PR objectives of updating the parents page for dynamic Corrily pricing.

To ensure that the removal of getParentsPageExperimentValue doesn't have unintended consequences, please run the following script to check for any remaining references to this method:

If the script returns any results, please review those occurrences and update them accordingly.

app/locale/en.js (6)

Line range hint 1-5957: Comprehensive update to localization strings

This update includes extensive additions and modifications to the English localization strings. The changes cover various new features and sections of the application, including:

  1. A new 'parents_v2' section with detailed information about coding classes and curriculum
  2. A new 'roblox' section related to CodeCombat's integration with Roblox
  3. A new 'pd_page' section for professional development offerings
  4. A new 'junior_page' section for the CodeCombat Junior product

These additions significantly expand the content and features available in the application, providing more comprehensive information for parents, students, and educators.


Line range hint 5240-5715: New 'parents_v2' section added

A comprehensive 'parents_v2' section has been added, which includes:

  1. Testimonials from parents and students
  2. Detailed information about class packages and features
  3. Curriculum overview and concepts covered
  4. Instructor profiles
  5. Extensive FAQ section

This addition provides a wealth of information for parents considering CodeCombat's online coding classes for their children. It covers various aspects of the program, from pricing to curriculum details, making it easier for parents to make informed decisions.


Line range hint 5716-5775: New 'roblox' section for Roblox integration

A new 'roblox' section has been added, which includes:

  1. Information about linking CodeCombat and Roblox accounts
  2. Details on rewards for account linking
  3. Descriptions of Play, Code, and Create features within Roblox
  4. FAQs specific to the Roblox integration

This addition introduces CodeCombat's integration with Roblox, allowing users to extend their coding experience into the Roblox platform. It provides clear information about the benefits of linking accounts and what users can expect from this integration.


Line range hint 5776-5806: New 'pd_page' section for professional development

A new 'pd_page' section has been added, which includes:

  1. Information about implementation training for educators
  2. Details on a 40+ hour professional development course
  3. Information about AP CSP professional development
  4. Links to download syllabi and course content

This addition provides comprehensive information about CodeCombat's professional development offerings for educators. It covers both implementation training and in-depth courses, including AP CSP preparation, which can help teachers effectively use CodeCombat and Ozaria in their classrooms.


Line range hint 5807-5957: New 'junior_page' section for CodeCombat Junior

A new 'junior_page' section has been added, which includes:

  1. Information about CodeCombat Junior, a K-5 curriculum
  2. Details on the scaffolded approach and accessibility features
  3. Information about adaptive learning and cross-curricular connections
  4. Links to resources like scope and sequence
  5. FAQs and trend information related to K-5 coding education

This addition introduces CodeCombat Junior, a new offering targeted at elementary school students. It provides comprehensive information about the curriculum's features, benefits, and how it adapts to younger learners' needs. This section will be valuable for parents and educators interested in introducing coding to younger children.


Line range hint 1-5957: Overall update to localization strings

This update to the English localization file (app/locale/en.js) includes significant additions and some modifications:

  1. Four major new sections have been added:

    • 'parents_v2': Comprehensive information about online coding classes
    • 'roblox': Details about CodeCombat's integration with Roblox
    • 'pd_page': Information about professional development offerings
    • 'junior_page': Introduction to CodeCombat Junior for K-5 students
  2. Minor updates and additions to existing sections throughout the file

These changes represent a substantial expansion of CodeCombat's offerings, including new features, partnerships, and educational resources. The additions cater to a wider audience, from young learners to educators seeking professional development.

app/views/landing-pages/parents-v2/FeaturesGrid.vue (2)

18-18: Approved import of Vuex helpers

The import of mapActions and mapGetters from Vuex is correct and aligns with their usage in the component.


45-45: Confirm the correctness of new content entry

The addition of the new row in rows for 'prompts allowance' appears to be consistent with the existing data structure.

Comment on lines 75 to 76
this.rows[2].content[1] = this.price
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle asynchronous data loading for 'price' computation

In the mounted() hook, you're setting this.rows[2].content[1] = this.price. However, since this.price depends on data loaded asynchronously in the created() hook via this.loadProducts(), there's a risk that this.price may not be initialized when mounted() runs.

Consider updating rows[2].content[1] after the data is loaded by watching for changes to basicAnnualSubscriptionForCurrentUser or this.price. Here's how you can implement it:

watch: {
  price(newVal) {
    if (newVal) {
      this.rows[2].content[1] = newVal
    }
  }
},

Alternatively, you can move the assignment inside the promise resolution of loadProducts() if it returns a promise:

created() {
  this.loadProducts().then(() => {
    this.rows[2].content[1] = this.price
  }).catch(e => {
    console.error('Error loading products in parents-v2', e)
  })
},

Comment on lines +68 to +73
try {
this.loadProducts()
} catch (e) {
console.error('Error loading products in parents-v2', e)
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential asynchronous errors in 'loadProducts'

While you're catching errors in the created() hook, loadProducts() might be an asynchronous action. If loadProducts() returns a promise, the try-catch block won't catch asynchronous errors.

Consider using .catch() to handle errors from the promise:

created() {
  this.loadProducts().catch(e => {
    console.error('Error loading products in parents-v2', e)
  })
},

Or use an async function:

async created() {
  try {
    await this.loadProducts()
  } catch (e) {
    console.error('Error loading products in parents-v2', e)
  }
},

Note: If you opt for an async created() hook, ensure that your environment supports it.

Comment on lines 61 to 63
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmmount') })
} else {
return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: origPrice })
Copy link
Contributor
10000

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify the i18n key for price formatting

The translation key parents_v2.grid_self_paced_year_price_without_currencya might be incorrect due to the trailing 'a'. Ensure that this key exists in your localization files. If it's a typo, it should likely be parents_v2.grid_self_paced_year_price_without_currency.

Apply this diff to correct the translation key:

- return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmount') })
+ return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currency', { price: p.get('formattedAmount') })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmmount') })
} else {
return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: origPrice })
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currency', { price: p.get('formattedAmount') })
} else {
return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: origPrice })

Comment on lines 54 to 58
origPrice = p.priceStringNoSymbol()
if (origPrice % 1 === 0) {
origPrice = Math.floor(origPrice)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure 'origPrice' is a number before performing arithmetic operations

The method p.priceStringNoSymbol() may return a string. When performing arithmetic operations like modulus, it's important to ensure that origPrice is a number to avoid unexpected results.

Convert origPrice to a number:

if (p) {
-   origPrice = p.priceStringNoSymbol()
+   origPrice = Number(p.priceStringNoSymbol())
    if (origPrice % 1 === 0) {
      origPrice = Math.floor(origPrice)
    }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
origPrice = p.priceStringNoSymbol()
if (origPrice % 1 === 0) {
origPrice = Math.floor(origPrice)
}
}
if (p) {
origPrice = Number(p.priceStringNoSymbol())
if (origPrice % 1 === 0) {
origPrice = Math.floor(origPrice)
}
}

Comment on lines 60 to 61
if (p?.get('formattedAmmount')) {
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmmount') })
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in 'formattedAmmount' property name

The property 'formattedAmmount' is misspelled. It should be 'formattedAmount' (with one 'm'). This typo could lead to undefined values when accessing the property.

Apply this diff to correct the typo:

- if (p?.get('formattedAmmount')) {
-   return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmmount') })
+ if (p?.get('formattedAmount')) {
+   return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currency', { price: p.get('formattedAmount') })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (p?.get('formattedAmmount')) {
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.get('formattedAmmount') })
if (p?.get('formattedAmount')) {
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currency', { price: p.get('formattedAmount') })

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 (1)
app/views/landing-pages/parents-v2/FeaturesGrid.vue (1)

Line range hint 18-97: Overall implementation looks good with room for minor improvements

The changes successfully implement dynamic pricing for the parents page, aligning with the PR objectives. Here's a summary of the improvements and suggestions:

  1. The Vuex integration for dynamic pricing is well-implemented.
  2. Error handling for asynchronous operations can be improved.
  3. There's a potential race condition in the mounted hook that should be addressed.
  4. The price computation logic can be simplified and made more robust.
  5. The changes to AI hints and prompts allowances need clarification.

To further improve the implementation:

  1. Consider adding unit tests for the price computed property to ensure it handles all scenarios correctly.
  2. Implement error boundaries or fallback UI for cases where price loading fails.
  3. Add comments explaining the complex price calculation logic for better maintainability.

These improvements will enhance the reliability and maintainability of the dynamic pricing feature.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4fd3b38 and 93a2ba5.

📒 Files selected for processing (1)
  • app/views/landing-pages/parents-v2/FeaturesGrid.vue (2 hunks)
🔇 Additional comments (4)
app/views/landing-pages/parents-v2/FeaturesGrid.vue (4)

18-18: LGTM: Vuex imports added

The addition of mapActions and mapGetters from Vuex is appropriate for implementing the dynamic pricing functionality.


45-46: Verify the purpose of AI hints and prompts allowance changes

The updates to AI hints (from 5 to 10) and prompts (from 100 to 50) allowances for the self-paced tier seem unrelated to the dynamic pricing implementation. Could you please clarify the reason for these changes?


67-74: LGTM: Price watcher implemented correctly

The watcher for the 'price' property is well-implemented. The use of immediate: true ensures that the rows are updated as soon as the component is created, which is good for initial rendering.


85-97: LGTM: Methods implemented correctly

The mapActions and updatePriceInRows method are well-implemented. The updatePriceInRows method efficiently updates the price in the rows data structure.

Comment on lines +48 to +66
computed: {
...mapGetters('products', ['basicAnnualSubscriptionForCurrentUser']),
price () {
const p = this.basicAnnualSubscriptionForCurrentUser
let origPrice = 99
if (p) {
origPrice = (p.amount / 100).toFixed(2)
if (origPrice % 1 === 0) {
origPrice = Math.floor(origPrice)
}
}
// we don't have coupon ID in parent page so no sale price here
if (p?.formattedAmmount) {
return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currencya', { price: p.formattedAmmount })
} else {
return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: origPrice })
}
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Refine price computation logic

The price computation looks good overall, but there are a few points to address:

  1. There's a typo in formattedAmmount. It should be formattedAmount.
  2. The decimal handling logic can be simplified.
  3. Consider using a more precise method for rounding.

Here's a suggested refactor:

computed: {
  ...mapGetters('products', ['basicAnnualSubscriptionForCurrentUser']),
  price() {
    const p = this.basicAnnualSubscriptionForCurrentUser
    if (p?.formattedAmount) {
      return $.i18n.t('parents_v2.grid_self_paced_year_price_without_currency', { price: p.formattedAmount })
    } else if (p) {
      const origPrice = (p.amount / 100).toFixed(2)
      return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: Number(origPrice) })
    }
    return $.i18n.t('parents_v2.grid_self_paced_year_price', { price: 99 })
  },
},

This refactor addresses the typo, simplifies the logic, and uses Number() for more precise rounding.

Comment on lines +75 to +81
created () {
try {
this.loadProducts()
} catch (e) {
console.error('Error loading products in parents-v2', e)
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling in created hook

The error handling in the created hook is good, but it can be improved to handle asynchronous errors more effectively.

Consider using an async function or attaching a .catch() to the loadProducts call:

created() {
  this.loadProducts().catch(e => {
    console.error('Error loading products in parents-v2', e)
  })
},

This ensures that any asynchronous errors from loadProducts are properly caught and logged.

Comment on lines 82 to 84
mounted () {
this.rows[2].content[1] = this.price
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Address potential race condition in mounted hook

The mounted hook updates the price in the rows, but there's a potential race condition if the price isn't loaded when mounted runs.

Consider moving this logic to the price watcher or the updatePriceInRows method:

watch: {
  price: {
    immediate: true,
    handler(newPrice) {
      this.updatePriceInRows(newPrice)
    },
  },
},
methods: {
  updatePriceInRows(newPrice) {
    this.rows = this.rows.map(row => {
      if (row.type === 'header') {
        return { ...row, content<
6D4E
/span>: [row.content[0], newPrice, row.content[2], row.content[3]] }
      }
      return row
    })
  },
},

This ensures that the rows are updated whenever the price changes, avoiding any race conditions.

@smallst smallst merged commit 87bfe96 into master Sep 29, 2024
2 checks passed
@smallst smallst deleted the yuqiang/parents-page-dynamic-corrily-price branch September 29, 2024 23:57
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.

2 participants
0