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

Fixing #6560: In postgres, importing changing channel content moves channel to top of list #7688

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

paulbusse
Copy link
Contributor

@paulbusse paulbusse commented Nov 12, 2020

Summary

The root cause is explained here.

  • replaced latest by max, should be more db independent
  • rewrote the function to prevent the query from being executed on every call to this function.

BTW. To get rid of the bad orders of you have to reorder them once after the patch is installed.

Reviewer guidance

Following tests have been executed:

  • adding new channels on existing channel list. (Postgres)
  • adding a channel on a new kolibri set up. (Postgres)
  • re-order the channels and added channels after that.
  • Ran the pytest suite (for sqlite compatibility)
    If there are more test I need to run let me know.

No migration is provided.

References

Contributor Checklist

PR process:

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Testing:

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

Reviewer Checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

- replaced 'latest' by 'max', should be more db independent
- rewrote the function preventing the query from being executed on every call
@jonboiser jonboiser added this to the 0.14.5 milestone Nov 12, 2020
@jonboiser jonboiser requested a review from jredrejo November 12, 2020 18:44
@@ -749,11 +750,10 @@ def calculate_included_languages(channel):


def calculate_next_order(channel, model=ChannelMetadata):
latest_order = model.objects.latest("order").order
Copy link
Member

Choose a reason for hiding this comment

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

I think the only line that must be changed is this one, just replacing it by
latest_order = model.objects.filter(order__isnull=False).latest("order").order
would solve the issue without more changes needed.
@paulbusse do you see any inconvenience in doing just this change?
If you don't see any issue in it, I think it's better than doing the new aggregations this PR introduces

Copy link
Member

Choose a reason for hiding this comment

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

bah, @paulbusse forget my previous comment, your solution is better for the case where no channels have been added yet.
Please, move the PR to be targeted at release-v0.14.x instead of develop and it's fine to be merged. Sorry for the noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jredrejo I kinda made the same journey :-)

Also reading this means that latest on a column with NULL values is not trustworthy. Django should standardize the usage of NULL values in the generated query, e.g. by adding NULLS LAST. MAX must, per the definition in the standard, skip over NULL values. (Just my €0.02)

Unless I'm overlooking something I'm not able to change the target of the PR.

Copy link
Member

@jredrejo jredrejo Nov 13, 2020

Choose a reason for hiding this comment

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

@jredrejo I kinda made the same journey :-)

Also reading this means that latest on a column with NULL values is not trustworthy. Django should standardize the usage of NULL values in the generated query, e.g. by adding NULLS LAST. MAX must, per the definition in the standard, skip over NULL values. (Just my €0.02)

Unless I'm overlooking something I'm not able to change the target of the PR.

I have changed the target in the GH UI, but the PR includes, logically, all the commits that are different between develop and release-v0.14.x. If you can, the steps I follow in these cases are:

  • From the issue6560b branch: git checkout -b keep_commit
  • From the release-v0.14.x:
 git branch -D  issue6560b
 git checkout -b issue6560b
 git cherry-pick id_of_your_commit
 git push -f 
 git branch -D keep_commit

If you have problems, don't worry, leave it as it is and we'll cherry-pick the commit from develop to release-v0.14.x

Copy link
Contributor Author

@paulbusse paulbusse Nov 13, 2020

Choose a reason for hiding this comment

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

I tried, but never done this before.

I got as far as the push. But that one gives an error

fatal: The current branch issue6560b has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin issue6560b

you forgot the -f to force the change ;)

(PS. The first command is git branch -D issue6560b, I assumed)

yes
Don't worry. We'll cherry pick it.

@jredrejo jredrejo changed the base branch from develop to release-v0.14.x November 13, 2020 08:23
@jredrejo jredrejo changed the base branch from release-v0.14.x to develop November 13, 2020 17:42
@jredrejo jredrejo merged commit 26e2868 into learningequality:develop Nov 13, 2020
@jredrejo jredrejo modified the milestones: 0.14.5, 0.14.4 Nov 13, 2020
@paulbusse paulbusse deleted the issue6560b branch November 15, 2020 05:43
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.

3 participants