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: about us models, migrations, and controllers #87

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

Conversation

czaja307
Copy link
Member

closes #84, #85, #86

i did it the way it is currently working on directus - there should be only 1 version of about us at any time (it's not the most advanced solution, but imo it'll stick)

skipped the query scopes, because i didn't think they were needed here

set the seeder to work in production environment - if you think that this is a bad approach, feel free to bring it up for discussion

@czaja307 czaja307 requested a review from mini-bomba January 20, 2025 16:23
@czaja307 czaja307 self-assigned this Jan 20, 2025
@Copilot Copilot bot review requested due to automatic review settings January 20, 2025 16:23

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • database/migrations/1737364296224_create_about_us_general_links_table.ts: Evaluated as low risk
  • database/seeders/about_us_seeder.ts: Evaluated as low risk
Comments suppressed due to low confidence (1)

app/models/about_us_general_link.ts:10

  • The type of 'linkType' should be consistent. It should be 'LinkType' instead of 'string' to match the column declaration.
linkType: "string",
This was linked to issues Jan 20, 2025
@czaja307 czaja307 requested a review from mini-bomba January 21, 2025 13:57
@czaja307
Copy link
Member Author

czaja307 commented Jan 21, 2025

@mini-bomba i've spoken to Simon, and he says they don't really need multiple versions - i think we should use KISS principle and leave it as is

@czaja307
Copy link
Member Author

added constraint, we will have to remember to remove delete option for this in admin panel, because autoincrement will get stuck then

@mini-bomba
Copy link
Member

then disable autoincrement 🧠

@mini-bomba
Copy link
Member

could even set the id default to the correct id and hide the column from adonis

@czaja307
Copy link
Member Author

on it

app/models/about_us_general.ts Show resolved Hide resolved
Comment on lines +21 to +28
async down() {
this.schema.raw(
`ALTER TABLE ${this.tableName} DROP CONSTRAINT IF EXISTS single_row;`,
);

this.schema.dropTable(this.tableName);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Dropping the constraint shouldn't be necessary since we're about to drop the table anyway

Comment on lines +16 to +17
@column({ isPrimary: true, serializeAs: null })
declare id: number;
Copy link
Member

Choose a reason for hiding this comment

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

what is this serializeAs prop about

Copy link
Member Author

Choose a reason for hiding this comment

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

id won't be shown when serialized to JSON

Copy link
Member

Choose a reason for hiding this comment

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

I'd think it would be more logical to put it in the model for about us text, not links
not sure if you meant to do this on the links model

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i meant to do it on the other model

Comment on lines +54 to +59
const result = await filesService.uploadFile(file as MultipartFile);

if (result instanceof Error) {
console.error(result);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

I really dislike how this fileService works, with it returning an error instead of just throwing.

Also the error should probably be rethrown, since it's a critical error anyway.

and of course it throws when I try to use it, looks like it doesn't try to create the storage dir if it doesn't exist
image

Copy link
Member Author

Choose a reason for hiding this comment

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

created new issue #96

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.

feat: about us controllers feat: about us models feat: about us migrations
2 participants