Skip to content

Script to compare backend models field vs it's corresponding frontend type fields. #1194

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Abhi-Bohora
Copy link
Contributor

@Abhi-Bohora Abhi-Bohora commented Mar 28, 2025

Contributor checklist


Description

This script compares the backend models fields against it's corresponding frontend type fields and reports the fields that are missing.
we can run this script by executing for example comparing communities/organizations/models.py against types/communities/organization.d.ts :

python3 backend/utils/type_checker.py backend/communities/organizations/models.py frontend/types/communities/organization.d.ts

the above command gives the following output which is shown below, which shows which fields are missing from the type file.
the model fields are converted to camelCase and than compared to fileds of type file, which is shown in the bracket(camelCase: 'fieldName').

Missing TypeScript fields found:
Field 'faqs' (camelCase: 'faqs') from model 'Organization' is missing in TypeScript types
Field 'terms_checked' (camelCase: 'termsChecked') from model 'Organization' is missing in TypeScript types
Field 'is_high_risk' (camelCase: 'isHighRisk') from model 'Organization' is missing in TypeScript types
No matching TypeScript interface found for model: OrganizationApplication
No matching TypeScript interface found for model: OrganizationApplicationStatus
Field 'org' (camelCase: 'org') from model 'OrganizationImage' is missing in TypeScript types
Field 'image' (camelCase: 'image') from model 'OrganizationImage' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationMember' is missing in TypeScript types
Field 'user' (camelCase: 'user') from model 'OrganizationMember' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationSocialLink' is missing in TypeScript types
No matching TypeScript interface found for model: OrganizationTask
Field 'donate_prompt' (camelCase: 'donatePrompt') from model 'OrganizationText' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationText' is missing in TypeScript types

Related issue

Copy link
Contributor

Thank you for the pull request! ❤️

The activist team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Development rooms once you're in. Also consider attending our bi-weekly Saturday developer syncs! It'd be great to meet you 😊

Copy link
Contributor

Maintainer Checklist

The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

  • The TypeScript, pytest and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The Playwright end to end and Zap penetration tests have been ran and are passing (if necessary)

  • The changelog has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@andrewtavis andrewtavis self-requested a review March 28, 2025 17:47
@Abhi-Bohora
Copy link
Contributor Author

@andrewtavis Hello, The work here is incomplete I am quite busy nowadays due to school work, I will keep working on this PR here and inform you when it's ready to review 😊

@andrewtavis
Copy link
Member

Sounds good, @Abhi-Bohora! Looking forward to bringing this in, and thanks so much for your efforts on these features that improve the dev experience so much 😊

Copy link

netlify bot commented Mar 28, 2025

Deploy Preview for activist-org ready!

Name Link
🔨 Latest commit fc56e6d
🔍 Latest deploy log https://app.netlify.com/sites/activist-org/deploys/681f6dd06b798100080c6f92
😎 Deploy Preview https://deploy-preview-1194--activist-org.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@andrewtavis
Copy link
Member

Merging in main to fix the frontend workflow, @Abhi-Bohora :)

@Abhi-Bohora
Copy link
Contributor Author

@andrewtavis hello Andrew...👋 Soon, I will give you an update on this. Sorry, I've been busy lately.

@andrewtavis
Copy link
Member

No worries on it, @Abhi-Bohora :) Thanks for letting me know though!

@Abhi-Bohora
Copy link
Contributor Author

Hello @andrewtavis 👋, I have created a script locally and ran against model and it's corresponding type, between backend/communities/organizations/models.py and frontend/types/communities/organization.d.ts and I get this as the output

Missing TypeScript fields found:
Field 'is_high_risk' (camelCase: 'isHighRisk') from model 'Organization' is missing in TypeScript types
Field 'terms_checked' (camelCase: 'termsChecked') from model 'Organization' is missing in TypeScript types
Field 'faqs' (camelCase: 'faqs') from model 'Organization' is missing in TypeScript types
No matching TypeScript interface found for model: OrganizationApplication
No matching TypeScript interface found for model: OrganizationApplicationStatus
Field 'image' (camelCase: 'image') from model 'OrganizationImage' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationImage' is missing in TypeScript types
Field 'user' (camelCase: 'user') from model 'OrganizationMember' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationMember' is missing in TypeScript types
Field 'org' (camelCase: 'org') from model 'OrganizationSocialLink' is missing in TypeScript types
No matching TypeScript interface found for model: OrganizationTask
Field 'org' (camelCase: 'org') from model 'OrganizationText' is missing in TypeScript types
Field 'donate_prompt' (camelCase: 'donatePrompt') from model 'OrganizationText' is missing in TypeScript types

can you please take a look and confirm is this what we are looking for ? 'donate_prompt' (camelCase: 'donatePrompt') donate_prompt will be converted to camelCase donatePrompt, then will be compared. and this (camelCase: 'donatePrompt') is for, what it is converting into and comparing. Thank you 😊

@andrewtavis
Copy link
Member

This is really nice, @Abhi-Bohora! Please send along the changes and we'll take a look 😊

@andrewtavis
Copy link
Member

Hey @Abhi-Bohora 👋 Checking in here really quick to see what the status is here :) From what you sent along I think we'd be ready for your local changes and then can finalize from there. Please let us know if there's something we can do to support! 😊

@Abhi-Bohora
Copy link
Contributor Author

sorry @andrewtavis this has taken this long, I have been quite busy with my work, I didn't get much time to sit and code, I have been doing this portion by portion in free time. Tomorrow I will raise a send a latest change to this and than we can review...😊

@andrewtavis
Copy link
Member

Sounds perfect, @Abhi-Bohora! And no stress on the timing 😊 Really gonna be great to get this in :) :)

@Abhi-Bohora Abhi-Bohora changed the title ⚠️in_progress: Script to compare backend models field vs it's corresponding frontend type fields. Script to compare backend models field vs it's corresponding frontend type fields. May 10, 2025
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