diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-08-29 06:32:29 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-08-29 06:32:29 -0400 |
commit | 1907c3b9e2223005697fca88abc051c72d67531d (patch) | |
tree | 699fba3f1296c2221c97fe1fdfb6548dbdabddb1 | |
parent | b32d06e251dd528ddde00e78792f3e0e0e0bcfb3 (diff) | |
download | Planner-master.tar.gz Planner-master.zip |
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | data_model/data.db | bin | 36864 -> 0 bytes | |||
-rw-r--r-- | data_model/db_update.gd | 23 | ||||
-rw-r--r-- | data_model/dbms.gd | 3 | ||||
-rw-r--r-- | data_model/schema.sql | 54 | ||||
-rw-r--r-- | data_model/test_data.sql | 20 | ||||
-rw-r--r-- | export_presets.cfg | 248 | ||||
-rw-r--r-- | project.godot | 8 |
8 files changed, 354 insertions, 3 deletions
@@ -1,7 +1,6 @@ .import addons export.cfg -export_presets.cfg *.translation .mono/ data_*/ diff --git a/data_model/data.db b/data_model/data.db Binary files differdeleted file mode 100644 index b3b0221..0000000 --- a/data_model/data.db +++ /dev/null diff --git a/data_model/db_update.gd b/data_model/db_update.gd new file mode 100644 index 0000000..595f1bc --- /dev/null +++ b/data_model/db_update.gd @@ -0,0 +1,23 @@ +class_name db_update + +static func update(DBMS): + while true: + var version = get_version(DBMS) + match version: + [0,1,0]: break + _: exec_sql_file(DBMS, "res://data_model/schema.sql") + #insert_test_data(DBMS) + +static func get_version(DBMS): + var version = DBMS.query("select * from Version", []) + return [0,0,0] if version.size() == 0 else [version[0]['major'],version[0]['minor'],version[0]['patch']] + +static func exec_sql_file(DBMS, file): + var f = File.new() + f.open(file, File.READ) + var sql = f.get_as_text() + f.close() + DBMS.query(sql,[]) + +static func insert_test_data(DBMS): + exec_sql_file(DBMS, "res://data_model/test_data.sql") diff --git a/data_model/dbms.gd b/data_model/dbms.gd index 43c514d..0508887 100644 --- a/data_model/dbms.gd +++ b/data_model/dbms.gd @@ -2,7 +2,7 @@ extends Node const sqlite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") -var db_name = "res://data_model/data.db" +var db_name = "user://data.db" var db func _init(): @@ -10,6 +10,7 @@ func _init(): db.path = db_name #db.verbosity_level = 3 db.open_db() + db_update.update(self) func query(sql, args): db.query_with_bindings(sql,args) diff --git a/data_model/schema.sql b/data_model/schema.sql new file mode 100644 index 0000000..c4a554d --- /dev/null +++ b/data_model/schema.sql @@ -0,0 +1,54 @@ +BEGIN TRANSACTION; +DROP TABLE IF EXISTS "Schedules"; +CREATE TABLE IF NOT EXISTS "Schedules" ( + "id" INTEGER, + "name" TEXT NOT NULL, + PRIMARY KEY("id") +); +DROP TABLE IF EXISTS "Tasks"; +CREATE TABLE IF NOT EXISTS "Tasks" ( + "id" INTEGER, + "name" TEXT NOT NULL, + "description" TEXT, + "frequency" INTEGER NOT NULL, + "estimated_length" INTEGER, + "date_completed" INTEGER, + PRIMARY KEY("id") +); +DROP TABLE IF EXISTS "TimeSlotTasks"; +CREATE TABLE IF NOT EXISTS "TimeSlotTasks" ( + "timeslot_id" INTEGER NOT NULL, + "task_id" INTEGER NOT NULL, + PRIMARY KEY("timeslot_id","task_id"), + FOREIGN KEY("task_id") REFERENCES "Tasks"("id") ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY("timeslot_id") REFERENCES "TimeSlots"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "SubTasks"; +CREATE TABLE IF NOT EXISTS "SubTasks" ( + "id" INTEGER, + "task_id" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "date_completed" INTEGER, + PRIMARY KEY("id"), + FOREIGN KEY("task_id") REFERENCES "Tasks"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "TimeSlots"; +CREATE TABLE IF NOT EXISTS "TimeSlots" ( + "id" INTEGER, + "schedule_id" INTEGER NOT NULL, + "start_time" INTEGER NOT NULL, + "end_time" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "date_completed" INTEGER, + PRIMARY KEY("id"), + FOREIGN KEY("schedule_id") REFERENCES "Schedules"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "Version"; +CREATE TABLE IF NOT EXISTS "Version" ( + "major" INTEGER NOT NULL, + "minor" INTEGER NOT NULL, + "patch" INTEGER NOT NULL +); +INSERT INTO "Schedules" VALUES (1,'default'); +INSERT INTO "Version" VALUES (0,1,0); +COMMIT; diff --git a/data_model/test_data.sql b/data_model/test_data.sql new file mode 100644 index 0000000..78ece96 --- /dev/null +++ b/data_model/test_data.sql @@ -0,0 +1,20 @@ +BEGIN TRANSACTION; +INSERT INTO "Tasks" VALUES (1,'Trash','Take out the trash.',2,5,NULL), + (2,'Laundry','Do the Laundry',4,120,NULL), + (3,'Pre-Workout Stretch',NULL,1,10,NULL); +INSERT INTO "TimeSlotTasks" VALUES (1,1), + (1,2), + (2,3); +INSERT INTO "SubTasks" VALUES (1,3,'arm circles',NULL), + (2,3,'heel raises into toe raises',NULL), + (3,3,'open hips',NULL), + (4,3,'open hips (side)',NULL), + (5,3,'karaoke',NULL), + (6,3,'knee to chest',NULL), + (7,3,'quad pull',NULL), + (8,3,'frankenstein',NULL), + (9,3,'lunge walk',NULL); +INSERT INTO "TimeSlots" VALUES (1,1,86400,88200,'Chore Block',NULL), + (2,1,45000,48600,'Workout',NULL), + (3,1,14000,20000,'test',NULL); +COMMIT; diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..f36e698 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,248 @@ +[preset.0] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="*.sql" +exclude_filter="data_model/test_data.sql" +export_path="./Planner.exe" +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +binary_format/64_bits=true +binary_format/embed_pck=false +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +codesign/enable=false +codesign/identity_type=0 +codesign/identity="" +codesign/password="" +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PoolStringArray( ) +application/modify_resources=false +application/icon="" +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" + +[preset.1] + +name="Android" +platform="Android" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="*.sql" +exclude_filter="data_model/test_data.sql" +export_path="./Planner.apk" +script_export_mode=1 +script_encryption_key="" + +[preset.1.options] + +custom_template/debug="" +custom_template/release="" +custom_build/use_custom_build=false +custom_build/export_format=0 +custom_build/min_sdk="" +custom_build/target_sdk="" +architectures/armeabi-v7a=true +architectures/arm64-v8a=true +architectures/x86=false +architectures/x86_64=false +keystore/debug="" +keystore/debug_user="" +keystore/debug_password="" +keystore/release="" +keystore/release_user="" +keystore/release_password="" +one_click_deploy/clear_previous_install=false +version/code=1 +version/name="1.0" +package/unique_name="org.godotengine.$genname" +package/name="" +package/signed=true +package/classify_as_game=false +package/retain_data_on_uninstall=false +package/exclude_from_recents=false +launcher_icons/main_192x192="" +launcher_icons/adaptive_foreground_432x432="" +launcher_icons/adaptive_background_432x432="" +graphics/opengl_debug=false +xr_features/xr_mode=0 +xr_features/hand_tracking=0 +xr_features/hand_tracking_frequency=0 +xr_features/passthrough=0 +screen/immersive_mode=true +screen/support_small=true +screen/support_normal=true +screen/support_large=true +screen/support_xlarge=true +user_data_backup/allow=false +command_line/extra_args="" +apk_expansion/enable=false +apk_expansion/SALT="" +apk_expansion/public_key="" +permissions/custom_permissions=PoolStringArray( ) +permissions/access_checkin_properties=false +permissions/access_coarse_location=false +permissions/access_fine_location=false +permissions/access_location_extra_commands=false +permissions/access_mock_location=false +permissions/access_network_state=false +permissions/access_surface_flinger=false +permissions/access_wifi_state=false +permissions/account_manager=false +permissions/add_voicemail=false +permissions/authenticate_accounts=false +permissions/battery_stats=false +permissions/bind_accessibility_service=false +permissions/bind_appwidget=false +permissions/bind_device_admin=false +permissions/bind_input_method=false +permissions/bind_nfc_service=false +permissions/bind_notification_listener_service=false +permissions/bind_print_service=false +permissions/bind_remoteviews=false +permissions/bind_text_service=false +permissions/bind_vpn_service=false +permissions/bind_wallpaper=false +permissions/bluetooth=false +permissions/bluetooth_admin=false +permissions/bluetooth_privileged=false +permissions/brick=false +permissions/broadcast_package_removed=false +permissions/broadcast_sms=false +permissions/broadcast_sticky=false +permissions/broadcast_wap_push=false +permissions/call_phone=false +permissions/call_privileged=false +permissions/camera=false +permissions/capture_audio_output=false +permissions/capture_secure_video_output=false +permissions/capture_video_output=false +permissions/change_component_enabled_state=false +permissions/change_configuration=false +permissions/change_network_state=false +permissions/change_wifi_multicast_state=false +permissions/change_wifi_state=false +permissions/clear_app_cache=false +permissions/clear_app_user_data=false +permissions/control_location_updates=false +permissions/delete_cache_files=false +permissions/delete_packages=false +permissions/device_power=false +permissions/diagnostic=false +permissions/disable_keyguard=false +permissions/dump=false +permissions/expand_status_bar=false +permissions/factory_test=false +permissions/flashlight=false +permissions/force_back=false +permissions/get_accounts=false +permissions/get_package_size=false +permissions/get_tasks=false +permissions/get_top_activity_info=false +permissions/global_search=false +permissions/hardware_test=false +permissions/inject_events=false +permissions/install_location_provider=false +permissions/install_packages=false +permissions/install_shortcut=false +permissions/internal_system_window=false +permissions/internet=false +permissions/kill_background_processes=false +permissions/location_hardware=false +permissions/manage_accounts=false +permissions/manage_app_tokens=false +permissions/manage_documents=false +permissions/manage_external_storage=false +permissions/master_clear=false +permissions/media_content_control=false +permissions/modify_audio_settings=false +permissions/modify_phone_state=false +permissions/mount_format_filesystems=false +permissions/mount_unmount_filesystems=false +permissions/nfc=false +permissions/persistent_activity=false +permissions/process_outgoing_calls=false +permissions/read_calendar=false +permissions/read_call_log=false +permissions/read_contacts=false +permissions/read_external_storage=false +permissions/read_frame_buffer=false +permissions/read_history_bookmarks=false +permissions/read_input_state=false +permissions/read_logs=false +permissions/read_phone_state=false +permissions/read_profile=false +permissions/read_sms=false +permissions/read_social_stream=false +permissions/read_sync_settings=false +permissions/read_sync_stats=false +permissions/read_user_dictionary=false +permissions/reboot=false +permissions/receive_boot_completed=false +permissions/receive_mms=false +permissions/receive_sms=false +permissions/receive_wap_push=false +permissions/record_audio=false +permissions/reorder_tasks=false +permissions/restart_packages=false +permissions/send_respond_via_message=false +permissions/send_sms=false +permissions/set_activity_watcher=false +permissions/set_alarm=false +permissions/set_always_finish=false +permissions/set_animation_scale=false +permissions/set_debug_app=false +permissions/set_orientation=false +permissions/set_pointer_speed=false +permissions/set_preferred_applications=false +permissions/set_process_limit=false +permissions/set_time=false +permissions/set_time_zone=false +permissions/set_wallpaper=false +permissions/set_wallpaper_hints=false +permissions/signal_persistent_processes=false +permissions/status_bar=false +permissions/subscribed_feeds_read=false +permissions/subscribed_feeds_write=false +permissions/system_alert_window=false +permissions/transmit_ir=false +permissions/uninstall_shortcut=false +permissions/update_device_stats=false +permissions/use_credentials=false +permissions/use_sip=false +permissions/vibrate=false +permissions/wake_lock=false +permissions/write_apn_settings=false +permissions/write_calendar=false +permissions/write_call_log=false +permissions/write_contacts=false +permissions/write_external_storage=false +permissions/write_gservices=false +permissions/write_history_bookmarks=false +permissions/write_profile=false +permissions/write_secure_settings=false +permissions/write_settings=false +permissions/write_sms=false +permissions/write_social_stream=false +permissions/write_sync_settings=false +permissions/write_user_dictionary=false diff --git a/project.godot b/project.godot index 864ccc1..0a95b08 100644 --- a/project.godot +++ b/project.godot @@ -28,12 +28,18 @@ _global_script_classes=[ { "class": "TimeSlot", "language": "GDScript", "path": "res://data_model/TimeSlot.gd" +}, { +"base": "Reference", +"class": "db_update", +"language": "GDScript", +"path": "res://data_model/db_update.gd" } ] _global_script_class_icons={ "DataHelpers": "", "SubTask": "", "Task": "", -"TimeSlot": "" +"TimeSlot": "", +"db_update": "" } [application] |