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

Jd 2023 02 codes delete background task #4965

Merged
merged 3 commits into from
Feb 24, 2023

Conversation

goapunk
Copy link
Contributor

@goapunk goapunk commented Feb 15, 2023

  • delete codes in background tasks
  • fix some tests
  • update translations

@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 681184b to c0dec1b Compare February 15, 2023 16:22
@goapunk
Copy link
Contributor Author

goapunk commented Feb 16, 2023

maybe fixes #4963

Copy link
Contributor

@Rineee Rineee left a comment

Choose a reason for hiding this comment

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

Lgtm! Although locally it does take the same amount of time for me (sth like 30 sec), but I guess worth trying on dev.
Do you also want to have a look @fuzzylogic2000 ?

@goapunk
Copy link
Contributor Author

goapunk commented Feb 16, 2023

Lgtm! Although locally it does take the same amount of time for me (sth like 30 sec), but I guess worth trying on dev. Do you also want to have a look @fuzzylogic2000 ?

Maybe we first deploy this branch and test it?

@goapunk goapunk changed the title Jd 2023 02 codes delete background task WIP: Jd 2023 02 codes delete background task Feb 16, 2023
@Rineee
Copy link
Contributor

Rineee commented Feb 16, 2023

Lgtm! Although locally it does take the same amount of time for me (sth like 30 sec), but I guess worth trying on dev. Do you also want to have a look @fuzzylogic2000 ?

Maybe we first deploy this branch and test it?

Good idea, yes!

Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

My thought when setting out to do this the first time was to have an extra package model instead of the number. That way when the package is downloaded, we only need to update that in the package model and can delete the plain tokens whenever it happens.
But let's try if this works first! When the actual downloading is the problem, that also won't help.

@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from c0dec1b to 7b3a747 Compare February 17, 2023 15:42
@goapunk goapunk added the migration-breaks-db PR contains migrations which can't be reverted label Feb 17, 2023
@goapunk goapunk changed the base branch from main to jd-2023-02-token-length-16 February 17, 2023 15:43
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch 2 times, most recently from 6548163 to 42d0b97 Compare February 17, 2023 16:00
Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

Is this ready to be reviewed?
And do we still need the package number here or is a package enough?

@goapunk goapunk force-pushed the jd-2023-02-token-length-16 branch from 6578c19 to 930b1e1 Compare February 20, 2023 10:35
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 42d0b97 to 4d447a8 Compare February 20, 2023 10:40
@goapunk goapunk changed the title WIP: Jd 2023 02 codes delete background task Jd 2023 02 codes delete background task Feb 20, 2023
@goapunk
Copy link
Contributor Author

goapunk commented Feb 20, 2023

Is this ready to be reviewed? And do we still need the package number here or is a package enough?

This is ready now I think. I'm not sure what you mean with the package_numbers?

Base automatically changed from jd-2023-02-token-length-16 to main February 20, 2023 12:18
@fuzzylogic2000 fuzzylogic2000 self-assigned this Feb 20, 2023
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 4d447a8 to 54576e1 Compare February 20, 2023 12:44
Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

The code looks good, but I haven't tried it out yet.
I still don't get why we need the package number and can not just use the package without the number. But I will have another look tomorrow morning with a fresh brain.
Maybe @Rineee can also check it out?

@fuzzylogic2000 fuzzylogic2000 removed their assignment Feb 20, 2023
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 54576e1 to eedb664 Compare February 20, 2023 15:51
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch 3 times, most recently from 72dca5c to 220c051 Compare February 22, 2023 15:34
@goapunk
Copy link
Contributor Author

goapunk commented Feb 22, 2023

@Rineee @fuzzylogic2000 this is ready for another round of reviews. But don't merge yet, needs squash and translations

Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

Yeah! It reads well. And it nearly works. But when I make a big batch, the "created" is False and not shown in the download section.

>>> TokenPackage.objects.all()
<QuerySet [<TokenPackage: TokenPackage object (1)>, <TokenPackage: TokenPackage object (2)>, <TokenPackage: TokenPackage object (3)>]>
>>> TokenPackage.objects.all()[0].module
<Module: Bürger*innenhaushalt (3 Phasen) - new bürherhaushalt s (1)>
>>> TokenPackage.objects.all()[1].module
<Module: Bürger*innenhaushalt (3 Phasen) - new bürherhaushalt s (1)>
>>> TokenPackage.objects.all()[2].module
<Module: Bürger*innenhaushalt (3 Phasen) - new bürherhaushalt s (1)>
>>> TokenPackage.objects.all()[0].size
10
>>> TokenPackage.objects.all()[1].size
1000000
>>> TokenPackage.objects.all()[2].size
200
>>> TokenPackage.objects.all()[0].created()
True
>>> TokenPackage.objects.all()[1].created()
False
>>> TokenPackage.objects.all()[2].created()
False

meinberlin/apps/votes/exports.py Show resolved Hide resolved
meinberlin/apps/votes/models.py Outdated Show resolved Hide resolved
@fuzzylogic2000
Copy link
Contributor

Yeah! It reads well. And it nearly works. But when I make a big batch, the "created" is False and not shown in the download section.

Ah! I didn't wait long enough and forgot about the batch size of 100.000. So, it was simply that not all tasks were run yet. 🤦 It works perfectly fine!

@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 220c051 to 8057ccb Compare February 23, 2023 10:26
@goapunk
Copy link
Contributor Author

goapunk commented Feb 23, 2023

@fuzzylogic2000 @Rineee rebased and added the translations, is ready to be merged now

@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from 8057ccb to b0a9f1b Compare February 23, 2023 17:44
@goapunk goapunk requested a review from Rineee February 23, 2023 17:45
Copy link
Contributor

@Rineee Rineee left a comment

Choose a reason for hiding this comment

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

The admin part does not really work, it throws an error when creating a token and also when changing a token, it adds 1 to the package size..

Also it did not show any packages in the dashboard, but that is most likely a me problem, I will check again tomorrow with fresh brain!

meinberlin/apps/votes/admin.py Outdated Show resolved Hide resolved
meinberlin/apps/votes/admin.py Outdated Show resolved Hide resolved
@goapunk goapunk force-pushed the jd-2023-02-codes-delete-background-task branch from b0a9f1b to f38128b Compare February 23, 2023 22:55
@Rineee
Copy link
Contributor

Rineee commented Feb 24, 2023

I managed again to produce an error 🙈 I had a package in which all codes were inactive and downloading that throws an error.. I dont know if that is too much of an edge case, but probably we should fix that anyway? Or what do you think @fuzzylogic2000 ?

Apart from that it works perfectly and from my side good to merge!

Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

Nice! I think it is a good solution with the packages and the size and so on!
Maybe we can also add the packages to the django-admin, so that they can be deleted if need be. But not in this PR anymore! :)

@fuzzylogic2000
Copy link
Contributor

I managed again to produce an error see_no_evil I had a package in which all codes were inactive and downloading that throws an error.. I dont know if that is too much of an edge case, but probably we should fix that anyway? Or what do you think @fuzzylogic2000 ?

Apart from that it works perfectly and from my side good to merge!

@Rineee Yeeees, I didn't try that, but will also do that. We should probably fix that even though it is an edge case.

@Rineee
Copy link
Contributor

Rineee commented Feb 24, 2023

I managed again to produce an error see_no_evil I had a package in which all codes were inactive and downloading that throws an error.. I dont know if that is too much of an edge case, but probably we should fix that anyway? Or what do you think @fuzzylogic2000 ?
Apart from that it works perfectly and from my side good to merge!

@Rineee Yeeees, I didn't try that, but will also do that. We should probably fix that even though it is an edge case.

@goapunk actually thought of it and raises the bad request here: https://github.com/liqd/a4-meinberlin/pull/4965/files#diff-ef2af1f23503a2f006e8048ad40751390211bb74ca18c6882369e290b66f022bR67
But I guess we should probably not show packages that have only inactive tokens?

@fuzzylogic2000
Copy link
Contributor

I managed again to produce an error see_no_evil I had a package in which all codes were inactive and downloading that throws an error.. I dont know if that is too much of an edge case, but probably we should fix that anyway? Or what do you think @fuzzylogic2000 ?
Apart from that it works perfectly and from my side good to merge!

@Rineee Yeeees, I didn't try that, but will also do that. We should probably fix that even though it is an edge case.

@goapunk actually thought of it and raises the bad request here: https://github.com/liqd/a4-meinberlin/pull/4965/files#diff-ef2af1f23503a2f006e8048ad40751390211bb74ca18c6882369e290b66f022bR67 But I guess we should probably not show packages that have only inactive tokens?

@goapunk @Rineee I agree. Let's fix that by not showing these packages. I will merge anyway and hope that noone tests that. :p

Traceback (most recent call last):
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 104, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/katharina/a4-meinberlin/venv/lib/python3.10/site-packages/adhocracy4/exports/views.py", line 38, in get
    for rownum, row in enumerate(self.export_rows(), start=1):
  File "/home/katharina/a4-meinberlin/meinberlin/apps/votes/exports.py", line 68, in export_rows
    raise BadRequest

Exception Type: BadRequest at /dashboard/modules/burgerinnenhaushalt-3-phasen-3/download-codes/export/
Exception Value: 

@fuzzylogic2000 fuzzylogic2000 merged commit 38f737f into main Feb 24, 2023
@fuzzylogic2000 fuzzylogic2000 deleted the jd-2023-02-codes-delete-background-task branch February 24, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration-breaks-db PR contains migrations which can't be reverted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants