-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bugfix challenge tags to normal tags after a challenge has ended/deleted #12341
Bugfix challenge tags to normal tags after a challenge has ended/deleted #12341
Conversation
Hi @tsukimi2 , I gave a look at the code (thanks for the client side test!) but it seems to simply add a check for |
Hmm actually there's a bug here... |
Okay @tsukimi2 , after some internal talks turns out the |
@paglias Sure, I think I can try handling the change from tag.challenge "string" to "boolean" in this PR, though probably I'll need to wait till the coming weekend to do that. Not sure whether there are other pages that are working currently based on this tag.challenge being a string currently as well. Anything I should pay attention to when trying to fix this bug? |
@tsukimi2 thanks! AFAIK there aren't other places where this issue is present because it was treated as a boolean everywhere except that it got saved as a string which caused this bug |
The changes are looking good @tsukimi2 , this is just going to need a migration to transform the Strings saved in the database to booleans, let me know if you want to add it or if we should handle it |
@paglias Sure, I can add the migration as well. |
…-tags-to-normal-tags
…-tags-to-normal-tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, the main issue is the use of monk
but it should be easy to change
|
||
while (true) { // eslint-disable-line no-constant-condition | ||
// eslint-disable-next-line no-await-in-loop | ||
const users = await dbUsers.find(query, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you import the User model
import { model as User } from '../../website/server/models/user';
and use that instead of monk
? We stopped using it some time ago, you can see an example here https://github.com/HabitRPG/habitica/blob/develop/migrations/users/full-stable.js#L68
arrayFilters: [{ 'element.challenge': 'true' }], | ||
}; | ||
|
||
await dbUsers.update(query, update, opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are two update calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will there ever be a case where challenge = false? If not, then maybe I'll just delete the update on challenge false from the migration script?
@paglias Please note that the most recent push in this PR is not working yet. Just want to ask a question based on the update. Previously, when using mock (instead of mongoose) to run the migration script, it was working fine (challenge field able to change from string to boolean correctly). However, once I changed from using mock to using User model as suggested, the migration script was no longer able to change the challenge field from string to boolean anymore. I tried to issue the update query directly in mongodb and it seems to work perfectly fine. The update query is as follow: db.users.updateOne({ I tried to debug the problem for quite some time but couldn't figure out what's wrong. Hope someone would provide some useful hints? Thanks. |
@tsukimi2 I think there are 2 options here:
and
for false values |
@SabreCat This is going to require the migration to be run after the PR is deployed |
Took a bit but we made it, thanks @tsukimi2 ! Noted towards your 4th tier |
Fixes #12276
Bugfix challenge tags to normal tags after a challenge has ended/deleted and added associated test cases.
Note
When running the newly added test cases, I noticed the following warnings, which I do not have any idea how to fix. Hopefully somebody can point me to the right direction? Thanks.
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> at src/components/tasks/user.vue