Files
yourpart3/src/houseworker.h
Torsten Schulz 1451225978 stabilized app
2026-01-14 14:37:21 +01:00

55 lines
1.7 KiB
C++

#ifndef HOUSEWORKER_H
#define HOUSEWORKER_H
#include "worker.h"
class HouseWorker : public Worker {
public:
HouseWorker(ConnectionPool &pool, MessageBroker &broker);
~HouseWorker() override;
protected:
void run() override;
private:
void performTask();
void performHouseStateChange();
static constexpr const char *QUERY_GET_NEW_HOUSE_DATA = R"(
SELECT
h.id AS house_id
FROM
falukant_type.house AS h
WHERE
random() < 0.0001
and "label_tr" != 'under_bridge';
)";
static constexpr const char *QUERY_ADD_NEW_BUYABLE_HOUSE = R"(
insert into falukant_data.buyable_house (house_type_id) values ($1);
)";
static constexpr const char *QUERY_UPDATE_BUYABLE_HOUSE_STATE = R"(
update falukant_data.buyable_house
set roof_condition = round(roof_condition - random() * (3 + 0 * id)),
floor_condition = round(floor_condition - random() * (3 + 0 * id)),
wall_condition = round(wall_condition - random() * (3 + 0 * id)),
window_condition = round(wall_condition - random() * (3 + 0 * id))
)";
static constexpr const char *QUERY_UPDATE_USER_HOUSE_STATE = R"(
update falukant_data.user_house
set roof_condition = round(roof_condition - random() * (3 + 0 * id)),
floor_condition = round(floor_condition - random() * (3 + 0 * id)),
wall_condition = round(wall_condition - random() * (3 + 0 * id)),
window_condition = round(window_condition - random() * (3 + 0 * id))
where house_type_id not in (
select id
from falukant_type.house h
where h.label_tr = 'under_bridge'
)
)";
};
#endif // HOUSEWORKER_H