criteria progress

This commit is contained in:
Sascha Kühl
2026-01-21 16:08:27 +01:00
parent ac514c3765
commit 328d164c05
58 changed files with 230 additions and 82 deletions
+67 -21
View File
@@ -48,7 +48,7 @@ using namespace work::models;
//
// If all checks succeed, the requested is fetched from
// the database.
// schema.attach<jobs::Payload>("payloads", make_polymorph("type"));
// schema.attach_as_base<jobs::Payload>("payloads", make_polymorph("type"));
// schema.attach<jobs::Payload, jobs::IdPayload>("id_list_payloads", make_polymorph_type("IdPayload"));
// schema.attach<jobs::Payload, jobs::IdListPayload>("id_payloads", make_polymorph_type("IdListPayload"));
// object::object_ptr<jobs::Payload> payload;
@@ -66,7 +66,7 @@ int main() {
logger::add_log_sink(logger::create_stdout_sink());
// sql::connection_pool<sql::connection> pool("postgres://news:news@127.0.0.1:15432/matador", 4);
sql::connection_pool pool("postgres://test:test123!@127.0.0.1:5432/matador", 4);
sql::connection_pool pool("postgres://test:test123!@127.0.0.1:15442/matador", 4);
utils::message_bus bus;
// query::schema ses({bus, pool});
@@ -97,26 +97,72 @@ int main() {
}
const auto conn = pool.acquire();
result = admin_schema.create(*conn);
if (!result) {
std::cout << "error: " << result.err() << std::endl;
return 0;
}
result = admin_schema.drop(*conn);
if (!result) {
std::cout << "error: " << result.err() << std::endl;
return 0;
}
// const std::string dns{"sqlite://demo.db"};
// sql::connection c(dns);
//
// result = c.open();
//
// // orm::session s()
// if (!result.is_ok()) {
// result = admin_schema.create(*conn);
// if (!result) {
// std::cout << "error: " << result.err() << std::endl;
// return 0;
// }
// result = admin_schema.drop(*conn);
// if (!result) {
// std::cout << "error: " << result.err() << std::endl;
// return 0;
// }
return 0;
/*
* const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.%2=%5.%6 AND %7" )
.arg( payloadTableAliasName,
payloadSqlMetaInfo.columnName( Payload::Attributes::idAttributeId() ),
Payload::staticSqlMetaInfo().tableName(),
Task::staticSqlMetaInfo().tableName(),
taskTableAliasName,
taskSqlMetaInfo.columnName( Task::Attributes::payloadAttributeId() ),
filter->idSelectStatement( taskTableAliasName ) );
*/
using namespace matador::query::meta;
using namespace matador::utils;
const auto payloads = PAYLOAD.as( "payloads" );
const auto tasks = TASK.as( "tasks" );
const auto stmt1 = query:: query::select( { tasks.payload, payloads.id } )
.from( tasks, payloads )
.where ( payloads.id == tasks.payload )
.str( conn->dialect() );
/*
const auto temporaryTable = status.addChildExc( fillTemporaryTable( idsInsidePayload ) );
const auto lookUpTableName = temporaryTable->tableName();
const auto& jobSqlMetaInfo = Job::staticSqlMetaInfo();
const auto& payloadSqlMetaInfo = Payload::staticSqlMetaInfo();
const auto& idPayloadSqlMetaInfo = IdPayload::staticSqlMetaInfo();
const auto statement = QString( "SELECT iPT.%1 FROM %2 iPT INNER JOIN %3 pT ON iPT.%4 = pT.%5 WHERE pT.%5 IN (SELECT %6 FROM %7 WHERE %8=?) AND iPT.%1 IN (SELECT %9 FROM %10)" )
.arg( idPayloadSqlMetaInfo.columnName( IdPayload::Attributes::payloadIdAttributeId() ) ) // %1
.arg( idPayloadSqlMetaInfo.tableName() ) // %2
.arg( payloadSqlMetaInfo.tableName() ) // %3
.arg( idPayloadSqlMetaInfo.columnName( IdPayload::Attributes::idAttributeId() ) ) // %4
.arg( payloadSqlMetaInfo.columnName( Payload::Attributes::idAttributeId() ) ) // %5
.arg( jobSqlMetaInfo.columnName( Job::Attributes::payloadAttributeId() ) ) // %6
.arg( jobSqlMetaInfo.tableName() ) // %7
.arg( jobSqlMetaInfo.columnName( Job::Attributes::stateSqlAttributeId() ) ) // %8
.arg( lookUpColName() ) // %9
.arg( lookUpTableName ); // %10
*/
query::table_column temp_id_col("ID");
query::table temporary("TempTable", { temp_id_col } );
const auto iPT = ID_PAYLOAD.as("iPT");
const auto pT = PAYLOAD.as("pT");
const auto stmt2 = query::query::select({ iPT.payload_id })
.from( iPT )
.join_left( pT ).on( iPT.id == pT.id )
.where(
in( pT.id, query::query::select({ JOB.payload }).from( JOB ).where( JOB.state == _) ) &&
in( iPT.payload_id, query::query::select({ temp_id_col }).from( temporary ) )
)
.str( conn->dialect() );
return 0;
}
+1 -1
View File
@@ -7,7 +7,7 @@
namespace work::core {
struct Model {
uint64_t id{};
int64_t id{};
uint64_t version{};
template<typename Operator>
+4
View File
@@ -5,6 +5,8 @@
#include "matador/object/collection.hpp"
#include "matador/query/meta_table_macro.hpp"
#include "matador/utils/foreign_attributes.hpp"
namespace work::models::jobs {
@@ -19,4 +21,6 @@ struct IdListPayload : Payload {
};
}
META_TABLE(id_list_payloads, ID_LIST_PAYLOAD, id, version, type, job)
#endif //ID_LIST_PAYLOAD_HPP
+4
View File
@@ -3,6 +3,8 @@
#include "Payload.hpp"
#include "matador/query/meta_table_macro.hpp"
namespace work::models::jobs {
struct IdPayload : Payload {
uint64_t payload_id{};
@@ -15,4 +17,6 @@ struct IdPayload : Payload {
};
}
META_TABLE(id_payloads, ID_PAYLOAD, id, version, type, job, payload_id)
#endif //ID_PAYLOAD_HPP
+4
View File
@@ -11,6 +11,8 @@
#include "matador/object/object_ptr.hpp"
#include "matador/query/meta_table_macro.hpp"
#include "matador/utils/base_class.hpp"
#include "matador/utils/foreign_attributes.hpp"
@@ -43,4 +45,6 @@ struct Job : core::Model {
}
META_TABLE(jobs, JOB, id, version, name, description, state, mode, created_at, payload, task, user_info)
#endif //JOB_HPP
+6 -2
View File
@@ -3,14 +3,16 @@
#include "../core/Model.hpp"
#include "matador/query/meta_table_macro.hpp"
#include "matador/utils/base_class.hpp"
#include "matador/utils/foreign_attributes.hpp"
namespace work::models::jobs {
struct Job;
struct Payload : core::Model {
std::string type;
matador::object::object_ptr<Job> job;
std::string type{};
matador::object::object_ptr<Job> job{};
template<typename Operator>
void process( Operator& op ) {
@@ -22,4 +24,6 @@ struct Payload : core::Model {
};
}
META_TABLE(payloads, PAYLOAD, id, version, type, job)
#endif //PAYLOAD_HPP
+4
View File
@@ -7,6 +7,8 @@
#include "matador/object/object_ptr.hpp"
#include "matador/query/meta_table_macro.hpp"
#include "matador/utils/base_class.hpp"
#include "matador/utils/foreign_attributes.hpp"
@@ -39,4 +41,6 @@ struct Task : core::Model {
};
}
META_TABLE(tasks, TASK, id, version, name, description, job_name, state, payload, job_mode, start_delay, interval, user_session_id)
#endif //TASK_HPP