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

Fix daily quest progress tracking #958

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

AminArria
Copy link
Contributor

@AminArria AminArria commented Sep 13, 2024

Motivation

Closes #926

Summary of changes

  • Change to preload all quests for the week
  • Filter out quests from not today when calculating progress

How to test it?

The following steps assume you are starting from clean DB (mix ecto.reset)

  1. Create a new user (easier to login with Unity)
  2. Run the following SQL to move the daily quests to yesterday
update users set last_daily_quest_generation_at = '2024-09-12 17:00:00';

update user_quests set activated_at = '2024-09-12 17:00:00', inserted_at= '2024-09-12 17:00:00', updated_at= '2024-09-12 17:00:00';

-- The line below could potentially mark the milestone quest as completed, but regardless I don't think its an issue
update user_quests set status = (case when random() < 0.5 then 'completed' else 'available' end) ;
  1. Login again through Unity to create todays quests

Now if you go to the quests tab you will see yesterday completed progress. Try to complete some from today to make sure everything still works as expected

Checklist

  • Tested the changes locally.
  • Reviewed the changes on GitHub, line by line.
  • This change requires new documentation.
    • Documentation has been added/updated.

@AminArria AminArria marked this pull request as ready for review September 13, 2024 18:37

quests_subquery =
from(user_quest in UserQuest,
as: :user_quest,
join: quest in assoc(user_quest, :quest),
as: :quest,
where:
(quest.type in ^["daily", "milestone"] and user_quest.inserted_at > ^start_of_date and
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the main culprit for the 0/6 error, it was preventing the fetching of previous day quests so as a result it was always showing as 0

Copy link
Contributor

@agustinesco agustinesco left a comment

Choose a reason for hiding this comment

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

LGTM! tested with yesterdays quests and is working

image

@Nico-Sanchez Nico-Sanchez merged commit c56927f into main Sep 13, 2024
1 check passed
@Nico-Sanchez Nico-Sanchez deleted the fix-daily-quest-progress-tracking branch September 13, 2024 19:31
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.

[BUG] Fix every quest type progress
3 participants