Api reference
components.gamification.public.business_logic ¶
actions ¶
player ¶
merge_users_in_gamification_component ¶
Support function for the "merge user" procedure: changes the source player user id to the target user id.
The targeted user id cannot already be a player, in this case this will fail
Source code in components/gamification/internal/business_logic/actions/player.py
components.gamification.public.commands ¶
app_group ¶
cleanup_duels ¶
cleanup_duels ¶
Cleanup duels that never had winners (usually if the player never opens the duel after results are ready) This also refunds both players
Source code in components/gamification/public/commands/cleanup_duels.py
cleanup_player_info ¶
cleanup_players ¶
cleanup_players ¶
Cleanup players (eg. those who are not insured anymore)
Source code in components/gamification/public/commands/cleanup_players.py
compute_month_winners ¶
compute_month_winners ¶
Compute monthly winners: - Team Challenge
Source code in components/gamification/public/commands/compute_month_winners.py
compute_week_winners ¶
compute_week_global_podium ¶
Find the global podium for the week amongst all alan members
Source code in components/gamification/public/commands/compute_week_winners.py
compute_week_winners ¶
Compute week winners - Walk Leaderboard
Source code in components/gamification/public/commands/compute_week_winners.py
compute_week_winners_retroactively ¶
Compute walk league week winners retroactively
Source code in components/gamification/public/commands/compute_week_winners.py
eligibility ¶
COUNTRIES_TO_APP_ID
module-attribute
¶
auto_register_future_accounts_for_gamification ¶
Create or update gamification eligibilities
Source code in components/gamification/public/commands/eligibility.py
reset_player_info ¶
reset_player_info ¶
Removes all gamification info linked to a player following withdrawal of consent
Source code in components/gamification/public/commands/reset_player_info.py
resync_players_preferences_with_customerio ¶
resync_players_preferences_with_customerio ¶
Resync all players preferences with customer CIO
Source code in components/gamification/public/commands/resync_players_preferences_with_customerio.py
team_challenge ¶
cleanup_team_challenges ¶
Cleanup team challenges
For challenges that are started - cleanup teams that have been created automatically at initialization but have only one player assigned and are not customized
Source code in components/gamification/public/commands/team_challenge.py
initialize_team_challenges ¶
Initialize team challenges
For accounts that are declared with a start date but not set yet: - initialize teams_size from number of enrolled players - generate default teams and captain assignation
Source code in components/gamification/public/commands/team_challenge.py
vouchers ¶
reconsolidate_gamification_vouchers_state ¶
Reconsolidate gamification vouchers state based on shopify discounts state - If discount code appears in a not cancelled order, the command will ensure the related voucher is marked as used - If discount code appears in a cancelled order, the command will ensure the related voucher is re-regenerated and not marked as used
Source code in components/gamification/public/commands/vouchers.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
components.gamification.public.controllers ¶
achievements ¶
AchievementsController ¶
Bases: BaseController
WHITELISTED_CLIENT_ACHIEVEMENT_CODES
module-attribute
¶
WHITELISTED_CLIENT_ACHIEVEMENT_CODES = {
activation_wheel,
baby_sleep_completed,
backpain_completed,
debug,
stress_program_completed,
play_scratch,
play_scratch_25_1,
play_scratch_25_2,
play_scratch_25_3,
play_scratch_25_4,
play_scratch_tp_card,
streak_7d,
streak_20d,
streak_50d,
streak_100d,
streak_150d,
streak_200d,
streak_250d,
streak_300d,
streak_365d,
streak_500d,
shop_eyewear_vto_frames_tried,
tp_card_added_to_wallet,
mo_first_discussion,
}
activities ¶
badges ¶
BadgesController ¶
Bases: BaseController
get_badges ¶
Source code in components/gamification/public/controllers/badges.py
mark_badges_as_seen ¶
Mark some badges as seen in the frontend. This ensures we don't show them again in the future.
Source code in components/gamification/public/controllers/badges.py
charity ¶
daily_challenge ¶
duels ¶
level ¶
play_history ¶
player ¶
players ¶
points ¶
purchases ¶
PurchasesController ¶
Bases: BaseController
get_purchases ¶
Source code in components/gamification/public/controllers/purchases.py
reactions ¶
ReactionsController ¶
Bases: BaseController
Controller for handling reactions.
This controller provides an endpoint to submit reactions from users. It accepts a POST request with the receiver's ID and the emoji representing the reaction. The reaction is then stored using the internal business logic.
records ¶
RecordsController ¶
Bases: BaseController
Handles requests related to personal records (e.g. most steps in a day, longest streak..)
get_records ¶
Returns the 4 current types of personal records (steps, streak, leaderboard position, berries)
Source code in components/gamification/public/controllers/records.py
stats ¶
stores ¶
streaks ¶
team_challenge ¶
users ¶
utils ¶
inject_player_context ¶
Source code in components/gamification/public/controllers/utils.py
vouchers ¶
walk_challenge ¶
walk_history ¶
components.gamification.public.dependency ¶
BeneficiaryData
dataclass
¶
GamificationAccountAdminEnrollmentData
dataclass
¶
GamificationDependency ¶
Bases: ABC
get_account_admin_enrollment
abstractmethod
¶
get_account_from_company
abstractmethod
¶
get_account_name
abstractmethod
¶
get_first_and_last_names_from_user_ids
abstractmethod
¶
get_player_ids_to_cleanup
abstractmethod
¶
get_reference_timezone
abstractmethod
¶
get_user_beneficiaries_cached
abstractmethod
¶
Get beneficiaries of a user's policy with policy information
get_user_enrollment
abstractmethod
¶
is_feature_enabled_for_user_id
abstractmethod
¶
Return True if the feature is enabled for the user, False otherwise
is_user_alaner
abstractmethod
¶
search_entity_users
abstractmethod
¶
GamificationUserEnrollmentData
dataclass
¶
UserBeneficiariesResult
dataclass
¶
Bases: DataClassJsonMixin
Result containing user beneficiaries and policy information.
__post_init__ ¶
get_app_dependency ¶
Get the GamificationDependency for the current Flask app
Source code in components/gamification/public/dependency.py
set_app_dependency ¶
Set the GamificationDependency for the current Flask app
Source code in components/gamification/public/dependency.py
components.gamification.public.enums ¶
achievement_definition ¶
AchievementCode ¶
Bases: AlanBaseEnum
Achievement codes for the gamification system. These codes are used to identify specific achievements that players can earn.
baby_sleep_completed
class-attribute
instance-attribute
¶
back_pain_program_exercise
class-attribute
instance-attribute
¶
breathing_qvct_zen_d1
class-attribute
instance-attribute
¶
care_incompatible_device
class-attribute
instance-attribute
¶
health_program_exercise
class-attribute
instance-attribute
¶
health_program_qvct_move_d2
class-attribute
instance-attribute
¶
health_program_qvct_move_d4
class-attribute
instance-attribute
¶
health_program_qvct_zen_d4
class-attribute
instance-attribute
¶
journaling_qvct_zen_d3
class-attribute
instance-attribute
¶
mo_first_discussion
class-attribute
instance-attribute
¶
play_scratch_tp_card
class-attribute
instance-attribute
¶
qvct_full_move_week
class-attribute
instance-attribute
¶
shop_contacts_purchase
class-attribute
instance-attribute
¶
shop_eyewear_purchase
class-attribute
instance-attribute
¶
shop_eyewear_vto_frames_tried
class-attribute
instance-attribute
¶
shop_wellbeing_purchase
class-attribute
instance-attribute
¶
stress_program_completed
class-attribute
instance-attribute
¶
stress_program_exercise
class-attribute
instance-attribute
¶
teleconsultation_attended
class-attribute
instance-attribute
¶
tp_card_added_to_wallet
class-attribute
instance-attribute
¶
walk_30min_milestone
class-attribute
instance-attribute
¶
walk_5min_milestone
class-attribute
instance-attribute
¶
walk_brisk_10min_milestone1
class-attribute
instance-attribute
¶
walk_brisk_10min_milestone2
class-attribute
instance-attribute
¶
walk_brisk_10min_milestone3
class-attribute
instance-attribute
¶
walk_brisk_20min_milestone1
class-attribute
instance-attribute
¶
walk_brisk_20min_milestone2
class-attribute
instance-attribute
¶
walk_brisk_20min_milestone3
class-attribute
instance-attribute
¶
walking_challenge_referral_use
class-attribute
instance-attribute
¶
walking_challenge_referral_used
class-attribute
instance-attribute
¶
walking_challenge_started
class-attribute
instance-attribute
¶
walking_challenge_top_10_percent
class-attribute
instance-attribute
¶
walking_challenge_top_5_percent
class-attribute
instance-attribute
¶
walking_challenge_week_1st
class-attribute
instance-attribute
¶
walking_challenge_week_2nd
class-attribute
instance-attribute
¶
walking_challenge_week_3rd
class-attribute
instance-attribute
¶
leagues ¶
components.gamification.public.helpers ¶
data_loader ¶
We need static data to exist in the local database for the component to work properly.
load_gamification_store_base_data ¶
Source code in components/gamification/public/helpers/data_loader.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
player_authorisation ¶
get_other_player_context_if_authorised ¶
Source code in components/gamification/public/helpers/player_authorisation.py
get_other_player_id_if_authorised ¶
get_other_player_id_if_authorised(
current_account_id,
current_player_id,
current_user_id,
other_user_id,
)
Source code in components/gamification/public/helpers/player_authorisation.py
shop_rewards ¶
compute_shop_berries_reward_for_product_cost ¶
Compute the berries reward for a product cost in the shop. The reward is calculated as 1% of the product cost, multiplied by 30. Make sure to keep in sync with computeShopBerriesRewardForProductCost
Source code in components/gamification/public/helpers/shop_rewards.py
components.gamification.public.services ¶
achievements ¶
declare_achievement_for_app_user ¶
declare_achievement_for_app_user(
app_user_id,
achievement_code,
berries=None,
collected=False,
commit=True,
)
Declare an achievement for a player identified by their app user ID.
Source code in components/gamification/public/services/achievements.py
list_achievements_for_app_user ¶
List all achievements for a player identified by their app user ID.
Source code in components/gamification/public/services/achievements.py
player ¶
remove_player_data ¶
Removes all gamification info linked to a player Connects purchases to a fake player Reset player object fields
Source code in components/gamification/public/services/player.py
vouchers ¶
create_onboarding_cookie_voucher ¶
Create an onboarding cookie voucher for the given user.
Source code in components/gamification/public/services/vouchers.py
get_onboarding_cookie_voucher_code_available ¶
Check if onboarding cookie vouchers are still available. Returns the voucher code if we haven't reached the limit of 200 vouchers (100 of each type). Returns None if we have reached the limit.
Source code in components/gamification/public/services/vouchers.py
has_onboarding_cookie_voucher ¶
Check if the user has an onboarding cookie voucher.