Compare commits

...
1 Commits
Author SHA1 Message Date
waozixyz 1b0e06dce2 fix tickmate import 2026-06-18 18:32:52 -03:00
11 changed files with 170 additions and 44 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
build-essential
ca-certificates
curl
libcurl4-openssl-dev
libdrm-dev
libegl1-mesa-dev
libgbm-dev
libgles2-mesa-dev
libsdl2-dev
patchelf
pkg-config
zip
+17 -13
View File
@@ -80,6 +80,8 @@ jobs:
name: Build Linux
runs-on: ubuntu-latest
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
@@ -88,22 +90,24 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Cache Linux apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: linux-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/linux-packages.txt') }}
restore-keys: |
linux-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Linux Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/linux-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get install -y \
build-essential \
ca-certificates \
curl \
libcurl4-openssl-dev \
libdrm-dev \
libegl1-mesa-dev \
libgbm-dev \
libgles2-mesa-dev \
libsdl2-dev \
patchelf \
pkg-config \
zip
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
- name: Install AppImage Tools
run: |
+4
View File
@@ -1,4 +1,8 @@
# Changelog
## [1.3.6] - 2026-06-18
### Fixed
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
## [1.3.5] - 2026-06-18
### Fixed
- Improved Android data import for `.db` backups, weekly habit rows, and import conflict handling.
+2 -2
View File
@@ -35,8 +35,8 @@ android {
defaultConfig {
minSdk 19
targetSdk 35
versionCode 33
versionName "1.3.5"
versionCode 34
versionName "1.3.6"
}
@@ -0,0 +1,2 @@
### Fixed
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
+2 -2
View File
@@ -3,7 +3,7 @@
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 3
#define INBE_VERSION_PATCH 5
#define INBE_VERSION_STRING "1.3.5"
#define INBE_VERSION_PATCH 6
#define INBE_VERSION_STRING "1.3.6"
#endif
+43 -5
View File
@@ -24,7 +24,7 @@ enum {
HABIT_WEEKLY_MONTH_DAYS = 31,
HABIT_WEEKLY_INITIAL_DAYS = HABIT_WEEKLY_MONTH_DAYS,
HABIT_WEEKLY_LOAD_DAYS = HABIT_WEEKLY_MONTH_DAYS,
HABIT_WEEKLY_MAX_DAYS = INBE_HABIT_MAX_DAYS
HABIT_WEEKLY_MAX_DAYS = 36500
};
/* Helper functions */
@@ -44,7 +44,7 @@ copy_text(char *dst, size_t dst_size, const char *src)
static int
habit_find_day(const InbeHabit *habit, int day_index)
{
if(habit == NULL)
if(habit == NULL || habit->days == NULL)
return -1;
for(int i = 0; i < habit->day_count; i++) {
if(habit->days[i].day_index == day_index)
@@ -53,6 +53,43 @@ habit_find_day(const InbeHabit *habit, int day_index)
return -1;
}
int
inbe_habit_reserve_days(InbeHabit *habit, int capacity)
{
InbeHabitDay *days;
int new_capacity;
if(habit == NULL || capacity <= habit->day_capacity)
return habit != NULL;
new_capacity = habit->day_capacity > 0 ? habit->day_capacity : 16;
while(new_capacity < capacity) {
if(new_capacity > 1073741823 / 2)
return 0;
new_capacity *= 2;
}
days = realloc(habit->days, (size_t)new_capacity * sizeof(*days));
if(days == NULL)
return 0;
memset(days + habit->day_capacity, 0,
(size_t)(new_capacity - habit->day_capacity) * sizeof(*days));
habit->days = days;
habit->day_capacity = new_capacity;
return 1;
}
void
inbe_habits_free(InbeHabits *habits)
{
if(habits == NULL)
return;
for(int i = 0; i < INBE_HABIT_MAX; i++) {
free(habits->items[i].days);
habits->items[i].days = NULL;
habits->items[i].day_count = 0;
habits->items[i].day_capacity = 0;
}
}
/* Core habits functions from habits.c */
int
inbe_habits_today_index(void)
@@ -97,7 +134,6 @@ inbe_habits_clear_days(InbeHabits *habits)
if(habit->days[d].day_index > 0 || habit->days[d].completed)
cleared++;
}
memset(habit->days, 0, sizeof(habit->days));
habit->day_count = 0;
}
return cleared;
@@ -124,6 +160,7 @@ inbe_habits_add_default_set(InbeHabits *habits)
if(habits == NULL)
return;
inbe_habits_free(habits);
memset(habits, 0, sizeof(*habits));
inbe_habits_add_seed(habits, "meditation", "Meditation", (Color){126, 183, 230, 255},
habit_activity_mask_for(EXERCISE_WIM_HOF) |
@@ -139,6 +176,7 @@ inbe_habits_delete(InbeHabits *habits, int index)
if(habits == NULL || index < 0 || index >= habits->count)
return;
free(habits->items[index].days);
for(int i = index; i < habits->count - 1; i++)
habits->items[i] = habits->items[i + 1];
habits->count--;
@@ -233,7 +271,7 @@ inbe_habit_set_day(InbeHabits *habits, int index, int day_index, int completed)
existing_index = habit_find_day(habit, day_index);
if(existing_index >= 0) {
habit->days[existing_index].completed = completed != 0;
} else if(completed && habit->day_count < INBE_HABIT_MAX_DAYS) {
} else if(completed && inbe_habit_reserve_days(habit, habit->day_count + 1)) {
habit->days[habit->day_count].day_index = day_index;
habit->days[habit->day_count].completed = 1;
habit->day_count++;
@@ -255,7 +293,7 @@ inbe_habit_toggle_day(InbeHabits *habits, int index, int day_index)
existing_index = habit_find_day(habit, day_index);
if(existing_index >= 0) {
habit->days[existing_index].completed = !habit->days[existing_index].completed;
} else if(habit->day_count < INBE_HABIT_MAX_DAYS) {
} else if(inbe_habit_reserve_days(habit, habit->day_count + 1)) {
habit->days[habit->day_count].day_index = day_index;
habit->days[habit->day_count].completed = 1;
habit->day_count++;
+4 -2
View File
@@ -17,7 +17,6 @@ enum {
INBE_HABIT_MAX = 10,
INBE_HABIT_ID_SIZE = 32,
INBE_HABIT_NAME_SIZE = 40,
INBE_HABIT_MAX_DAYS = 366,
HABIT_LINKED_ENTRY_MAX = 128,
HABIT_LINKED_PATH_SIZE = 80
};
@@ -45,8 +44,9 @@ typedef struct InbeHabit {
Color color;
int sync_mode;
int sync_activity;
InbeHabitDay days[INBE_HABIT_MAX_DAYS];
InbeHabitDay *days;
int day_count;
int day_capacity;
} InbeHabit;
typedef struct InbeHabits {
@@ -89,8 +89,10 @@ typedef struct HabitLinkedContext {
/* Core habits functions */
void inbe_habits_init(InbeHabits *habits);
void inbe_habits_free(InbeHabits *habits);
void inbe_habits_save(const InbeHabits *habits);
int inbe_habits_clear_days(InbeHabits *habits);
int inbe_habit_reserve_days(InbeHabit *habit, int capacity);
int inbe_habits_today_index(void);
int inbe_habit_completed_day(const InbeHabit *habit, int day_index);
int inbe_habit_completed_today(const InbeHabit *habit);
+24 -14
View File
@@ -1045,6 +1045,7 @@ inbe_storage_habits_load(void *habits_ptr)
if(habits == NULL || g_storage.db == NULL)
return 0;
inbe_habits_free(habits);
memset(habits, 0, sizeof(*habits));
if(sqlite3_prepare_v2(g_storage.db,
"SELECT id,name,color_r,color_g,color_b,sync_mode,sync_activity "
@@ -1067,12 +1068,16 @@ inbe_storage_habits_load(void *habits_ptr)
for(int i = 0; i < habits->count; i++) {
if(sqlite3_prepare_v2(g_storage.db,
"SELECT local_date,completed FROM habit_days WHERE habit_id=?1 ORDER BY local_date LIMIT 366",
"SELECT local_date,completed FROM habit_days WHERE habit_id=?1 ORDER BY local_date",
-1, &stmt, NULL) != SQLITE_OK)
continue;
bind_text(stmt, 1, habits->items[i].id);
while(habits->items[i].day_count < INBE_HABIT_MAX_DAYS && sqlite3_step(stmt) == SQLITE_ROW) {
while(sqlite3_step(stmt) == SQLITE_ROW) {
int d = habits->items[i].day_count++;
if(!inbe_habit_reserve_days(&habits->items[i], habits->items[i].day_count)) {
habits->items[i].day_count--;
break;
}
habits->items[i].days[d].day_index = sqlite3_column_int(stmt, 0);
habits->items[i].days[d].completed = sqlite3_column_int(stmt, 1) != 0;
}
@@ -1502,6 +1507,17 @@ import_tickmate_db(sqlite3 *src)
"SELECT ticks._track_id,tracks.name,ticks.year,ticks.month,ticks.day "
"FROM ticks JOIN tracks ON tracks._id=ticks._track_id",
-1, &stmt, NULL) == SQLITE_OK) {
if(sqlite3_prepare_v2(g_storage.db,
"INSERT INTO habit_days(habit_id,local_date,completed,updated_at) "
"VALUES(?1,?2,1,?3) "
"ON CONFLICT(habit_id,local_date) DO UPDATE SET "
"completed=CASE WHEN habit_days.completed!=0 THEN habit_days.completed ELSE excluded.completed END,"
"updated_at=CASE WHEN habit_days.completed!=0 THEN habit_days.updated_at ELSE excluded.updated_at END",
-1, &write_stmt, NULL) != SQLITE_OK) {
sqlite3_finalize(stmt);
stmt = NULL;
goto finish;
}
while(sqlite3_step(stmt) == SQLITE_ROW) {
char import_habit_id[64];
char local_habit_id[INBE_STORAGE_ID_SIZE];
@@ -1514,30 +1530,24 @@ import_tickmate_db(sqlite3 *src)
if(name == NULL || name[0] == '\0')
continue;
if(year <= 0 || month <= 0 || month > 12 || day <= 0 || day > 31)
/* Tickmate stores Android Calendar.MONTH values: January is 0. */
if(year <= 0 || month < 0 || month > 11 || day <= 0 || day > 31)
continue;
local_date = year * 10000 + month * 100 + day;
local_date = year * 10000 + (month + 1) * 100 + day;
snprintf(import_habit_id, sizeof(import_habit_id), "tickmate-%d", track_id);
if(!resolve_import_habit_id(import_habit_id, name, local_habit_id,
sizeof(local_habit_id)))
continue;
if(sqlite3_prepare_v2(g_storage.db,
"INSERT INTO habit_days(habit_id,local_date,completed,updated_at) "
"VALUES(?1,?2,1,?3) "
"ON CONFLICT(habit_id,local_date) DO UPDATE SET "
"completed=CASE WHEN habit_days.completed!=0 THEN habit_days.completed ELSE excluded.completed END,"
"updated_at=CASE WHEN habit_days.completed!=0 THEN habit_days.updated_at ELSE excluded.updated_at END",
-1, &write_stmt, NULL) != SQLITE_OK)
continue;
sqlite3_reset(write_stmt);
sqlite3_clear_bindings(write_stmt);
bind_text(write_stmt, 1, local_habit_id);
sqlite3_bind_int(write_stmt, 2, local_date);
sqlite3_bind_int64(write_stmt, 3, imported_at);
if(sqlite3_step(write_stmt) == SQLITE_DONE)
ok = 1;
sqlite3_finalize(write_stmt);
write_stmt = NULL;
}
}
finish:
sqlite3_finalize(stmt);
sqlite3_finalize(write_stmt);
exec_sql("COMMIT");
+56 -2
View File
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
static int g_failures = 0;
@@ -608,6 +609,7 @@ static void
write_tickmate_database(const char *path)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char *error = NULL;
check_true("open tickmate db", sqlite3_open(path, &db) == SQLITE_OK);
@@ -625,12 +627,51 @@ write_tickmate_database(const char *path)
"INSERT INTO tracks(_id,name,description,icon,enabled,color,\"order\") "
"VALUES(1,'Meditation','Silenced my mind','',1,8925,0);"
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
"VALUES(1,2026,6,13,0,0,0,0);",
"VALUES(1,2026,0,1,0,0,0,0),"
"(1,2026,1,2,0,0,0,0),"
"(1,2026,2,3,0,0,0,0),"
"(1,2026,3,4,0,0,0,0),"
"(1,2026,4,5,0,0,0,0),"
"(1,2026,5,6,0,0,0,0),"
"(1,2026,6,7,0,0,0,0),"
"(1,2026,7,8,0,0,0,0),"
"(1,2026,8,9,0,0,0,0),"
"(1,2026,9,10,0,0,0,0),"
"(1,2026,10,11,0,0,0,0),"
"(1,2026,11,12,0,0,0,0);",
NULL, NULL, &error) == SQLITE_OK);
if(error != NULL) {
fprintf(stderr, "tickmate setup SQL error: %s\n", error);
sqlite3_free(error);
}
check_true("prepare large tickmate insert",
sqlite3_prepare_v2(db,
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
"VALUES(1,?1,?2,?3,0,0,0,0)",
-1, &stmt, NULL) == SQLITE_OK);
if(stmt != NULL) {
struct tm day;
check_true("begin large tickmate insert", sqlite3_exec(db, "BEGIN", NULL, NULL, NULL) == SQLITE_OK);
memset(&day, 0, sizeof(day));
day.tm_year = 2025 - 1900;
day.tm_mon = 0;
day.tm_mday = 1;
day.tm_hour = 12;
mktime(&day);
for(int i = 0; i < 12000; i++) {
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_bind_int(stmt, 1, day.tm_year + 1900);
sqlite3_bind_int(stmt, 2, day.tm_mon);
sqlite3_bind_int(stmt, 3, day.tm_mday);
check_true("large tickmate insert row", sqlite3_step(stmt) == SQLITE_DONE);
day.tm_mday++;
mktime(&day);
}
check_true("commit large tickmate insert", sqlite3_exec(db, "COMMIT", NULL, NULL, NULL) == SQLITE_OK);
sqlite3_finalize(stmt);
}
sqlite3_close(db);
}
@@ -650,7 +691,20 @@ test_tickmate_db_import(void)
memset(&habits, 0, sizeof(habits));
check_true("tickmate habits load", inbe_storage_habits_load(&habits));
check_int("tickmate habit count", habits.count, 1);
check_true("tickmate habit day", inbe_habit_completed_day(&habits.items[0], 20260613));
check_true("tickmate january day", inbe_habit_completed_day(&habits.items[0], 20260101));
check_true("tickmate february day", inbe_habit_completed_day(&habits.items[0], 20260202));
check_true("tickmate march day", inbe_habit_completed_day(&habits.items[0], 20260303));
check_true("tickmate april day", inbe_habit_completed_day(&habits.items[0], 20260404));
check_true("tickmate may day", inbe_habit_completed_day(&habits.items[0], 20260505));
check_true("tickmate june day", inbe_habit_completed_day(&habits.items[0], 20260606));
check_true("tickmate july day", inbe_habit_completed_day(&habits.items[0], 20260707));
check_true("tickmate august day", inbe_habit_completed_day(&habits.items[0], 20260808));
check_true("tickmate september day", inbe_habit_completed_day(&habits.items[0], 20260909));
check_true("tickmate october day", inbe_habit_completed_day(&habits.items[0], 20261010));
check_true("tickmate november day", inbe_habit_completed_day(&habits.items[0], 20261111));
check_true("tickmate december day", inbe_habit_completed_day(&habits.items[0], 20261212));
check_true("tickmate loads thousands of days",
inbe_habit_completed_day(&habits.items[0], 20571108));
check_true("tickmate habit name", strcmp(habits.items[0].name, "Meditation") == 0);
inbe_storage_close();
+4 -4
View File
@@ -3,8 +3,8 @@
IDI_APP_ICON ICON "inbe.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,5,0
PRODUCTVERSION 1,3,5,0
FILEVERSION 1,3,6,0
PRODUCTVERSION 1,3,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -21,11 +21,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "1.3.5"
VALUE "FileVersion", "1.3.6"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "1.3.5"
VALUE "ProductVersion", "1.3.6"
END
END
BLOCK "VarFileInfo"