feat: add user_id index to profiles table for faster lookups

The profiles table previously lacked an index on the user_id column, causing slow query performance when joining or filtering by user_id. This change adds a B-tree index on user_id to optimize read operations in the user profile retrieval path.
This commit is contained in:
2025-12-04 23:28:01 +00:00
parent 3247d6c40b
commit c880ff6b3f
13 changed files with 923 additions and 7 deletions
+81
View File
@@ -0,0 +1,81 @@
#include "test_utils.h"
UnittestTestResult_t* test_method_ref_parse_static(void) {
UNITTEST_BEGIN_TEST("TestMethodRef", "test_method_ref_parse_static");
const char *source =
"public class Test {\n"
" public static int getValue() {\n"
" return 42;\n"
" }\n"
" public static int main() {\n"
" return Test.getValue();\n"
" }\n"
"}\n";
RAVA_TEST_PARSER_OK(_unittest_result, source, "Parser should handle static method call");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_method_ref_syntax(void) {
UNITTEST_BEGIN_TEST("TestMethodRef", "test_method_ref_syntax");
const char *source =
"public class Test {\n"
" public static int helper(int x) {\n"
" return x * 2;\n"
" }\n"
" public static int main() {\n"
" return helper(21);\n"
" }\n"
"}\n";
RAVA_TEST_RUN(_unittest_result, source, "Test", "main", 42, "Should execute helper method");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_method_ref_ir_generation(void) {
UNITTEST_BEGIN_TEST("TestMethodRef", "test_method_ref_ir_generation");
const char *source =
"public class Test {\n"
" public static int getValue() {\n"
" return 100;\n"
" }\n"
" public static int main() {\n"
" return getValue();\n"
" }\n"
"}\n";
RAVA_TEST_IR_OK(_unittest_result, source, "IR generation should succeed");
UNITTEST_END_TEST();
}
int main(int argc, char **argv) {
UnittestConfig_t *config = unittest_config_create();
config->verbosity = 2;
if (argc > 1 && strcmp(argv[1], "--json") == 0) {
config->output_format = UNITTEST_FORMAT_JSON;
config->use_colors = false;
}
UnittestTestSuite_t *suite = unittest_test_suite_create("Method Reference Tests");
UnittestTestCase_t *tc = unittest_test_case_create("TestMethodRef");
unittest_test_case_add_result(tc, test_method_ref_parse_static());
unittest_test_case_add_result(tc, test_method_ref_syntax());
unittest_test_case_add_result(tc, test_method_ref_ir_generation());
unittest_test_suite_add_test_case(suite, tc);
unittest_generate_report(suite, config);
int failures = suite->total_failed + suite->total_errors;
unittest_test_suite_destroy(suite);
unittest_config_destroy(config);
return failures > 0 ? 1 : 0;
}
+60
View File
@@ -0,0 +1,60 @@
#include "test_utils.h"
UnittestTestResult_t* test_socket_create_server(void) {
UNITTEST_BEGIN_TEST("TestSockets", "test_socket_create_server");
RAVA_TEST_RUN(_unittest_result,
"public class Test {\n"
" public static int main() {\n"
" ServerSocket server = new ServerSocket(9999);\n"
" server.close();\n"
" return 1;\n"
" }\n"
"}\n",
"Test", "main", 1, "Should create and close ServerSocket");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_socket_create_multiple(void) {
UNITTEST_BEGIN_TEST("TestSockets", "test_socket_create_multiple");
RAVA_TEST_RUN(_unittest_result,
"public class Test {\n"
" public static int main() {\n"
" ServerSocket server1 = new ServerSocket(9997);\n"
" ServerSocket server2 = new ServerSocket(9996);\n"
" server1.close();\n"
" server2.close();\n"
" return 2;\n"
" }\n"
"}\n",
"Test", "main", 2, "Should create multiple ServerSockets");
UNITTEST_END_TEST();
}
int main(int argc, char **argv) {
UnittestConfig_t *config = unittest_config_create();
config->verbosity = 2;
if (argc > 1 && strcmp(argv[1], "--json") == 0) {
config->output_format = UNITTEST_FORMAT_JSON;
config->use_colors = false;
}
UnittestTestSuite_t *suite = unittest_test_suite_create("Socket Tests");
UnittestTestCase_t *tc = unittest_test_case_create("TestSockets");
unittest_test_case_add_result(tc, test_socket_create_server());
unittest_test_case_add_result(tc, test_socket_create_multiple());
unittest_test_suite_add_test_case(suite, tc);
unittest_generate_report(suite, config);
int failures = suite->total_failed + suite->total_errors;
unittest_test_suite_destroy(suite);
unittest_config_destroy(config);
return failures > 0 ? 1 : 0;
}