vulyk.blueprints.gamification package¶
Subpackages¶
- vulyk.blueprints.gamification.core package
- Submodules
- vulyk.blueprints.gamification.core.events module
- vulyk.blueprints.gamification.core.foundations module
- vulyk.blueprints.gamification.core.parsing module
- vulyk.blueprints.gamification.core.queries module
- vulyk.blueprints.gamification.core.rules module
- vulyk.blueprints.gamification.core.state module
- Module contents
- vulyk.blueprints.gamification.models package
vulyk.blueprints.gamification.listeners module¶
-
vulyk.blueprints.gamification.listeners.
track_events
(sender: object, answer: vulyk.models.tasks.AbstractAnswer) → None[source]¶ The most important gear of the gamification module.
- Parameters
sender (object) – Sender
answer (AbstractAnswer) – Current finished task’s answer instance
- Return type
None
-
vulyk.blueprints.gamification.listeners.
get_actual_rules
(state: vulyk.blueprints.gamification.core.state.UserState, task_type_name: str, now: datetime.datetime) → Iterator[vulyk.blueprints.gamification.core.rules.Rule][source]¶ Returns a list of eligible rules.
vulyk.blueprints.gamification.services module¶
Services module
-
class
vulyk.blueprints.gamification.services.
DonationResult
[source]¶ Bases:
enum.Enum
An enumeration to represent different results of donation process.
-
BEGGAR
= 2¶
-
ERROR
= 666¶
-
LIAR
= 3¶
-
STINGY
= 1¶
-
SUCCESS
= 0¶
-
-
class
vulyk.blueprints.gamification.services.
DonationsService
(user: vulyk.models.user.User, fund_id: str, amount: decimal.Decimal)[source]¶ Bases:
object
Class hides mildly complex donation logic from cruel outer world.
-
donate
() → vulyk.blueprints.gamification.services.DonationResult[source]¶ - Perform a donation process:
check if there is enough active money to spare
check if fund exists
try to decrease amount of coins on current account
create and save an event
- Returns
One of DonationResult enum values: SUCCESS - everything went okay; STINGY - you tried to donate nothing; BEGGAR - you have less money than tried to spare; LIAR - you passed non-existent fund; ERROR - sh*t happened :( .
- Return type
-
-
class
vulyk.blueprints.gamification.services.
StatsService
[source]¶ Bases:
object
Facade, the root stats collector to provide aggregated data from different repositories.
-
classmethod
projects_count
(user: vulyk.models.user.User) → int[source]¶ Aggregate the number of batches in which user has done at least single tiny task.
- Parameters
user (User) – Current user
- Returns
Number of batches
- Return type
int
-
classmethod
state_of_user
(user: vulyk.models.user.User) → Optional[vulyk.blueprints.gamification.core.state.UserState][source]¶ Return current state of given user
- Returns
Object which holds aggregated values
on user current state for the registered user and None otherwise :rtype: Optional[UserState]
-
classmethod
tasks_done_by_user
(user: vulyk.models.user.User) → int[source]¶ Returns optional of the total number of tasks were finished by user.
- Parameters
user (User) – Current user
- Returns
Number of tasks done or None
- Return type
int
-
classmethod
total_money_donated
() → float[source]¶ Count and return total amount of money donated by all users to all foundations
- Returns
Total amount in UAH
- Return type
float
-
classmethod
total_money_donated_by_user
(user: vulyk.models.user.User) → float[source]¶ Count and return total amount of money donated by current user
- Returns
Total amount in UAH
- Return type
float
-
classmethod
total_money_earned
() → float[source]¶ Count and return total amount of money earned by all users on all tasks
- Returns
Total amount in UAH
- Return type
float
-
classmethod
total_number_of_open_tasks
() → int[source]¶ Count and return number of open tasks in all projects
- Returns
Number of open tasks
- Return type
int
-
classmethod
total_number_of_users
() → int[source]¶ Count and return number of users registered in the system
- Returns
Number of active users
- Return type
int
-
classmethod
total_time_for_user
(user: vulyk.models.user.User) → int[source]¶ Count and return number of hours, spent on the site doing tasks.
- Parameters
user (User) – Current user
- Returns
Full hours
- Return type
int
-
classmethod
Module contents¶
The core of gamification sub-project.