Added filtered_tasks constructor
This commit is contained in:
parent
5b5b36c041
commit
dbc57e38c9
30
src/dodo.c
30
src/dodo.c
@ -29,8 +29,16 @@ int view_all(sqlite3 *db){
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_filtered_tasks(filtered_tasks* task){
|
||||||
// sql generators TODO: might be able to boil this down to 1 func
|
task->table = NULL;
|
||||||
|
task->selected_columns = NULL;
|
||||||
|
task->title = NULL;
|
||||||
|
task->new_title = NULL;
|
||||||
|
task->active_id = -1;
|
||||||
|
task->status = NULL;
|
||||||
|
task->project_tag = NULL;
|
||||||
|
task->due_date = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: this really needs to only be one function with update_stmt()
|
// TODO: this really needs to only be one function with update_stmt()
|
||||||
int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task){
|
int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task){
|
||||||
@ -352,6 +360,8 @@ int view_tasks(sqlite3 *db){
|
|||||||
// Set the table and cols to be printed
|
// Set the table and cols to be printed
|
||||||
filtered_tasks* tasks = malloc(sizeof(filtered_tasks));
|
filtered_tasks* tasks = malloc(sizeof(filtered_tasks));
|
||||||
// TODO check that malloc is ok
|
// TODO check that malloc is ok
|
||||||
|
|
||||||
|
init_filtered_tasks(tasks);
|
||||||
tasks->table = "tasks";
|
tasks->table = "tasks";
|
||||||
tasks->selected_columns = "active_id, title, due_date";
|
tasks->selected_columns = "active_id, title, due_date";
|
||||||
|
|
||||||
@ -390,10 +400,9 @@ int add_new_task(sqlite3 *db, int argc, char** argv){
|
|||||||
sqlite3_stmt* out_stmt;
|
sqlite3_stmt* out_stmt;
|
||||||
|
|
||||||
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
||||||
task->table = "tasks";
|
|
||||||
|
|
||||||
task->title = NULL;
|
init_filtered_tasks(task);
|
||||||
task->due_date = NULL;
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
parse_args(argc, argv, task);
|
||||||
|
|
||||||
@ -424,7 +433,7 @@ int update_task_status(sqlite3 *db, int argc, char** argv){
|
|||||||
sqlite3_stmt* out_stmt;
|
sqlite3_stmt* out_stmt;
|
||||||
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
||||||
|
|
||||||
task->status = NULL;
|
init_filtered_tasks(task);
|
||||||
task->table = "tasks";
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
parse_args(argc, argv, task);
|
||||||
@ -453,7 +462,7 @@ int complete_task(sqlite3 *db, int argc, char** argv){
|
|||||||
sqlite3_stmt* out_stmt;
|
sqlite3_stmt* out_stmt;
|
||||||
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
||||||
|
|
||||||
task->status = NULL;
|
init_filtered_tasks(task);
|
||||||
task->table = "tasks";
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
parse_args(argc, argv, task);
|
||||||
@ -479,8 +488,8 @@ int update_task(sqlite3 *db, int argc, char** argv){
|
|||||||
sqlite3_stmt* out_stmt;
|
sqlite3_stmt* out_stmt;
|
||||||
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
||||||
|
|
||||||
task->new_title = NULL;
|
init_filtered_tasks(task);
|
||||||
task->due_date = NULL;
|
|
||||||
task->table = "tasks";
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
parse_args(argc, argv, task);
|
||||||
@ -508,7 +517,8 @@ int del_task(sqlite3 *db, int argc, char** argv){
|
|||||||
sqlite3_stmt* out_stmt;
|
sqlite3_stmt* out_stmt;
|
||||||
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
filtered_tasks* task = malloc(sizeof(filtered_tasks));
|
||||||
|
|
||||||
task->active_id = 0;
|
init_filtered_tasks(task);
|
||||||
|
|
||||||
task->table = "tasks";
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
parse_args(argc, argv, task);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#define BACKLOG_COL_START (FIXED_COLUMN_WIDTH + 1)
|
#define BACKLOG_COL_START (FIXED_COLUMN_WIDTH + 1)
|
||||||
#define BLOCKED_COL_START ( (2 * FIXED_COLUMN_WIDTH) + 1)
|
#define BLOCKED_COL_START ( (2 * FIXED_COLUMN_WIDTH) + 1)
|
||||||
|
|
||||||
|
// TODO maybe I should make another module that is strictly
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
int year;
|
int year;
|
||||||
int month;
|
int month;
|
||||||
@ -37,6 +39,9 @@ typedef struct {
|
|||||||
int callback(void *NotUsed, int argc, char **argv, char **azColName);
|
int callback(void *NotUsed, int argc, char **argv, char **azColName);
|
||||||
int view_all(sqlite3 *db);
|
int view_all(sqlite3 *db);
|
||||||
|
|
||||||
|
// filtered_tasks constructor
|
||||||
|
void init_filtered_tasks(filtered_tasks* task);
|
||||||
|
|
||||||
// sql generators TODO: might be able to boil this down to 1 func
|
// sql generators TODO: might be able to boil this down to 1 func
|
||||||
int gen_sql_update_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
int gen_sql_update_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
||||||
int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
||||||
|
Loading…
Reference in New Issue
Block a user