Database Operations
loglife.app.db.tables.users
User table operations and data model.
This module defines the User data class and the UsersTable class for handling database interactions related to users.
User
dataclass
User data model representing a row in the users table.
Source code in src/loglife/app/db/tables/users.py
12 13 14 15 16 17 18 19 20 21 22 23 | |
UsersTable
Handles database operations for the users table.
Source code in src/loglife/app/db/tables/users.py
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 | |
__init__(conn)
Initialize the UsersTable with a database connection.
Source code in src/loglife/app/db/tables/users.py
29 30 31 | |
create(phone_number, timezone, referred_by_id=None)
Create a new user record.
Source code in src/loglife/app/db/tables/users.py
57 58 59 60 61 62 63 64 65 66 67 68 | |
delete(user_id)
Delete a user record.
Source code in src/loglife/app/db/tables/users.py
112 113 114 115 | |
get(user_id)
Retrieve a user by their ID.
Source code in src/loglife/app/db/tables/users.py
33 34 35 36 37 38 39 40 | |
get_all()
Retrieve all users.
Source code in src/loglife/app/db/tables/users.py
51 52 53 54 55 | |
get_by_phone(phone_number)
Retrieve a user by their phone number.
Source code in src/loglife/app/db/tables/users.py
42 43 44 45 46 47 48 49 | |
set_state(user_id, state, state_data=None)
Update the user's conversational state.
Source code in src/loglife/app/db/tables/users.py
107 108 109 110 | |
update(user_id, phone_number=None, timezone=None, send_transcript_file=None, referred_by_id=None)
Update a user record with provided fields.
Source code in src/loglife/app/db/tables/users.py
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 | |
loglife.app.db.tables.goals
Goal table operations and data model.
This module defines the Goal data class and the GoalsTable class for handling database interactions related to user goals.
Goal
dataclass
Goal data model.
Source code in src/loglife/app/db/tables/goals.py
12 13 14 15 16 17 18 19 20 21 22 | |
GoalsTable
Handles database operations for the user_goals table.
Source code in src/loglife/app/db/tables/goals.py
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 | |
__init__(conn)
Initialize the GoalsTable with a database connection.
Source code in src/loglife/app/db/tables/goals.py
28 29 30 | |
create(user_id, goal_emoji, goal_description, boost_level=1)
Create a new goal record.
Source code in src/loglife/app/db/tables/goals.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
delete(goal_id)
Delete a goal record.
Source code in src/loglife/app/db/tables/goals.py
102 103 104 105 | |
get(goal_id)
Retrieve a goal by its ID.
Source code in src/loglife/app/db/tables/goals.py
32 33 34 35 36 | |
get_all_with_reminders()
Retrieve all goals that have a reminder set.
Source code in src/loglife/app/db/tables/goals.py
44 45 46 47 48 | |
get_by_user(user_id)
Retrieve all goals for a user.
Source code in src/loglife/app/db/tables/goals.py
38 39 40 41 42 | |
update(goal_id, goal_emoji=None, goal_description=None, boost_level=None, reminder_time=None)
Update a goal record with provided fields.
Source code in src/loglife/app/db/tables/goals.py
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 | |
loglife.app.db.tables.ratings
Rating table operations and data model.
This module defines the Rating data class and the RatingsTable class for handling database interactions related to goal ratings.
Rating
dataclass
Rating data model.
Source code in src/loglife/app/db/tables/ratings.py
13 14 15 16 17 18 19 20 21 22 | |
RatingsTable
Handles database operations for the goal_ratings table.
Source code in src/loglife/app/db/tables/ratings.py
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 | |
__init__(conn)
Initialize the RatingsTable with a database connection.
Source code in src/loglife/app/db/tables/ratings.py
28 29 30 | |
create(user_goal_id, rating)
Create a new rating record.
Source code in src/loglife/app/db/tables/ratings.py
54 55 56 57 58 | |
delete(rating_id)
Delete a rating record.
Source code in src/loglife/app/db/tables/ratings.py
92 93 94 95 | |
get(rating_id)
Retrieve a rating by its ID.
Source code in src/loglife/app/db/tables/ratings.py
32 33 34 35 36 | |
get_all()
Retrieve all ratings.
Source code in src/loglife/app/db/tables/ratings.py
48 49 50 51 52 | |
get_by_goal_and_date(user_goal_id, rating_date)
Retrieve the most recent rating for a goal on a given date.
Source code in src/loglife/app/db/tables/ratings.py
38 39 40 41 42 43 44 45 46 | |
update(rating_id, user_goal_id=None, rating=None, rating_date=None)
Update a rating record with provided fields.
Source code in src/loglife/app/db/tables/ratings.py
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 | |
loglife.app.db.tables.audio_journals
Audio journal table operations and data model.
This module defines the AudioJournalEntry data class and the AudioJournalsTable class for handling database interactions related to audio journal entries.
AudioJournalEntry
dataclass
Audio journal entry data model.
Source code in src/loglife/app/db/tables/audio_journals.py
12 13 14 15 16 17 18 19 20 | |
AudioJournalsTable
Handles database operations for the audio_journals table.
Source code in src/loglife/app/db/tables/audio_journals.py
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 | |
__init__(conn)
Initialize the AudioJournalsTable with a database connection.
Source code in src/loglife/app/db/tables/audio_journals.py
26 27 28 | |
create(user_id, transcription_text, summary_text)
Create a new audio journal entry.
Source code in src/loglife/app/db/tables/audio_journals.py
52 53 54 55 56 57 58 | |
delete(entry_id)
Delete an audio journal entry.
Source code in src/loglife/app/db/tables/audio_journals.py
69 70 71 72 | |
get(entry_id)
Retrieve an audio journal entry by its ID.
Source code in src/loglife/app/db/tables/audio_journals.py
30 31 32 33 34 | |
get_all()
Retrieve all audio journal entries.
Source code in src/loglife/app/db/tables/audio_journals.py
46 47 48 49 50 | |
get_by_user(user_id)
Retrieve all audio journal entries for a user.
Source code in src/loglife/app/db/tables/audio_journals.py
36 37 38 39 40 41 42 43 44 | |
update(entry_id, transcription_text, summary_text)
Update an existing audio journal entry.
Source code in src/loglife/app/db/tables/audio_journals.py
60 61 62 63 64 65 66 67 | |