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

removal of awards #185

Merged
merged 19 commits into from
Nov 20, 2023
Merged

removal of awards #185

merged 19 commits into from
Nov 20, 2023

Conversation

lilfade
Copy link
Contributor

@lilfade lilfade commented Nov 1, 2023

Just a generic removal of awards, seems the community was okay with this for the time being as it's not used.

@lilfade lilfade added please review I want to be sure what I did won't cause problems needs feedback Requires a greater consensus to make an informed decision frontend Visual issues, improvements, bugs or other aspects relating mostly to the front end labels Nov 1, 2023
@lilfade lilfade self-assigned this Nov 1, 2023
@nobodyatroot
Copy link
Member

nobodyatroot commented Nov 1, 2023

More a question for @melroy89 since I haven't messed with any translations lately, but is it necessary to remove all instances of "awards" from every translation file or will the Weblate two way sync happen automagically once it has been removed only from the English translation?

@e-five256
Copy link
Member

I learned in #157 (comment) that the non-en translation files shouldn't be touched in this repo

@nobodyatroot
Copy link
Member

I learned in #157 (comment) that the non-en translation files shouldn't be touched in this repo

That's what my understanding was as well, @lilfade you should undo those commits to the non-english translations, they'll all follow the English base translation once Weblate syncs after merging.

@lilfade
Copy link
Contributor Author

lilfade commented Nov 1, 2023

Good to know, will get that done here after bit.

@lilfade
Copy link
Contributor Author

lilfade commented Nov 1, 2023

Fixed, still unsure on the modifications to the tables that I commented out, not a Postgres wizard so anyone willing to check that out and push a fix if needed would be welcome. This should just remove the dead code no one wants currently so should be good to review and turn into a PR now if everything looks good.

@melroy89
Copy link
Member

melroy89 commented Nov 1, 2023

More a question for @melroy89 since I haven't messed with any translations lately, but is it necessary to remove all instances of "awards" from every translation file or will the Weblate two way sync happen automagically once it has been removed only from the English translation?

No, just English translation is fine. English is configured to be the "base" language in Weblate. And due to the two way sync we have setup correctly, this will automatically put in Weblate and remove it from other languages as well. I hope 😆 . See "Monolingual base language file" (within Weblate->Mbin->Mbin->Settings->Files):

image

@lilfade lilfade marked this pull request as ready for review November 1, 2023 14:38
$this->addSql('DROP TABLE award_type');
$this->addSql('DROP TABLE award');
// Dropped Due to src/Entity/ApActivity.php, needs testing
// $this->addSql('ALTER TABLE ap_activity DROP CONSTRAINT fk_68292518a76ed395');
Copy link
Member

@melroy89 melroy89 Nov 1, 2023

Choose a reason for hiding this comment

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

Let's indeed not remove/drop ap_activity. Is still used after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea noticed that one. Unsure why it relies on the award for the foreign key though on this one. Thoughts on a fix for this one?

Copy link
Member

Choose a reason for hiding this comment

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

There was a "many-on-one" DB relation as you can see in ApActivity.php between this ap_activity table and the users as well as the ap_activity and the magazines.

I think dropping ALTER TABLE ap_activity DROP user_id & ALTER TABLE ap_activity DROP magazine_id might be fine .. let me check the tables in DB later today..

Copy link
Member

Choose a reason for hiding this comment

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

I would've expected the FK on ap_activity to user_id on user to help make sure all activitypub events correspond to a local user. I'm not really understanding what it has to do with awards 🤔

Copy link
Member

@melroy89 melroy89 Nov 1, 2023

Choose a reason for hiding this comment

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

@e-five256 yea I didn't check the DB to be honest yet (now I did). But if the user_id and magazine_id has a relation only towards the awards table it can be removed. If the same foreign keys are used for other reasons, then not.

Again looking at the change of @lilfade he only removed the Doctrine annotations, which are NOT just comments. These annotations are talking something about the DB design. So if you wish the remove the many-to-one relation related to the awards table (inversedBy), then also remove public User $user; and public ?Magazine $magazine; lines below the Doctrine annotations (after all the annotations are belong to the PHP lines below that).

Meaning all these lines then need to be removed (but keep subject_id):

    #[ManyToOne(targetEntity: User::class, inversedBy: 'awards')]
    #[JoinColumn(nullable: false, onDelete: 'CASCADE')]
    public User $user;
    #[ManyToOne(targetEntity: Magazine::class, inversedBy: 'awards')]
    #[JoinColumn(nullable: true, onDelete: 'CASCADE')]
    public ?Magazine $magazine;

If you want to keep the user_id and magazine_id then you need to understand how/why this data was related to the awards table. And if we want to keep it or not. We need to understand the underlying code and how it was used (or not used at all?).

For doctrine see: https://www.doctrine-project.org/projects/doctrine-orm/en/2.16/reference/association-mapping.html#one-to-many-bidirectional

Copy link
Member

@melroy89 melroy89 Nov 1, 2023

Choose a reason for hiding this comment

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

I also checked the data in my database for this ap_activity table. I don't have any rows.. This table used at all??

SELECT * FROM ap_activity;
 id | user_id | magazine_id | subject_id | type | body | created_at 
----+---------+-------------+------------+------+------+------------
(0 rows)

@nobodyatroot nobodyatroot self-requested a review November 1, 2023 16:37
nobodyatroot
nobodyatroot previously approved these changes Nov 1, 2023
Copy link
Member

@nobodyatroot nobodyatroot left a comment

Choose a reason for hiding this comment

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

@melroy89 can double check me, but so far so good. I migrated a base docker dev environment with the test fixtures loaded over to this branch without any issues.

Copy link
Member

@melroy89 melroy89 left a comment

Choose a reason for hiding this comment

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

@lilfade Either keep the User & Magazine relation of the ApActivity and think about another Doctrine annotation. Or if you want to remove this ManyToOne relation of the ApActivity, you need to remove the PHP lines belonging to the Doctrine annotation...

Read more about doctrine first, before continuing with this change or even before considering merging this PR: https://www.doctrine-project.org/projects/doctrine-orm/en/2.16/reference/association-mapping.html#one-to-many-bidirectional

@nobodyatroot yea, I doubled checked, but the Doctrine changes are incorrect.

@nobodyatroot nobodyatroot dismissed their stale review November 1, 2023 19:57

Problem with doctrine migration

@lilfade lilfade marked this pull request as draft November 1, 2023 23:17
@melroy89
Copy link
Member

melroy89 commented Nov 3, 2023

No update?

@melroy89 melroy89 dismissed their stale review November 3, 2023 21:56

I don't want to be the blocker

@nobodyatroot
Copy link
Member

nobodyatroot commented Nov 19, 2023

Please re-review migration, I think it looks OK now, also fixed merge conflicts since this is 3 weeks old.

e-five256
e-five256 previously approved these changes Nov 19, 2023
Copy link
Member

@e-five256 e-five256 left a comment

Choose a reason for hiding this comment

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

lgtm

@nobodyatroot
Copy link
Member

nobodyatroot commented Nov 19, 2023

I won't merge this until @melroy89 and/or others approve, probably a good habit for anyone merging doctrine migrations... having as many eyes on it as possible.

@nobodyatroot nobodyatroot changed the title removal of awards removal of awards, add DB optimization Nov 19, 2023
@nobodyatroot nobodyatroot removed the needs feedback Requires a greater consensus to make an informed decision label Nov 19, 2023
@nobodyatroot
Copy link
Member

nobodyatroot commented Nov 19, 2023

Branch is now running live on kbin.run

e-five256
e-five256 previously approved these changes Nov 19, 2023
config/kbin_routes/magazine.yaml Outdated Show resolved Hide resolved
migrations/Version20231119145850.php Outdated Show resolved Hide resolved
@nobodyatroot nobodyatroot changed the title removal of awards, add DB optimization removal of awards Nov 19, 2023
@nobodyatroot nobodyatroot merged commit d54d6ae into main Nov 20, 2023
7 checks passed
@nobodyatroot nobodyatroot deleted the award-removal branch November 20, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Visual issues, improvements, bugs or other aspects relating mostly to the front end please review I want to be sure what I did won't cause problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants