This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
forked from ofri/Open-Knesset
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from alonisser/master
Mainly fixing #513 (or allowing to fix after data updates with batch or specific triggering for updating vore properties)
- Loading branch information
Showing
8 changed files
with
161 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
STANDS_FOR_THRESHOLD = 0.66 |
36 changes: 36 additions & 0 deletions
36
laws/management/commands/recalculate_votes_properties_current_knesset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import print_function | ||
|
||
from django.core.management.base import BaseCommand | ||
from optparse import make_option | ||
|
||
from laws.models import Vote | ||
from mks.models import Knesset | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Recalculate vote properties for current knesset" | ||
|
||
option_list = BaseCommand.option_list + ( | ||
make_option( | ||
'-n', action='store_true', dest="dryrun", default=False, | ||
help='Dry run, changes nothing in the db, just display results' | ||
), | ||
) | ||
|
||
def handle(self, *args, **options): | ||
|
||
start_date = Knesset.objects.current_knesset().start_date | ||
|
||
votes_to_update = Vote.objects.filter(time__gte=start_date) | ||
logger.info('Found {0} votes to update since {1}'.format(votes_to_update.count(), start_date)) | ||
if options['dryrun']: | ||
logger.info("Not updating the db, dry run was specified") | ||
return | ||
|
||
for vote in votes_to_update: | ||
|
||
vote.update_vote_properties() | ||
logger.info(u'Recalculated vote properties for {0}'.format(vote)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.