averbraeck / housinggame-admin

Administrator app for the Housing Game
https://housing-game.tbm.tudelft.nl
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Adapt admin app for addition of houseround table #23

Closed averbraeck closed 9 months ago

averbraeck commented 9 months ago

The database has a new houseround table that replaces the bid table. The code needs to reflect these changes. See https://github.com/averbraeck/housinggame-common/issues/4 for the design information.

The measure table points to this houseround table instead of to the house table. This has to be changed as well.

averbraeck commented 9 months ago

Changes have been made, but code still has to be tested. Especially the joins for the tables for house in HouseRound and MeasureType and PlayerRound in Measure are tricky. As an example:

.addEntry(new TableEntryPickRecord(Tables.MEASURE.MEASURETYPE_ID)
        .setPickTable(data, Tables.MEASURE.join(Tables.MEASURETYPE)
                .on(Tables.MEASURE.MEASURETYPE_ID.eq(Tables.MEASURETYPE.ID))
                .and(Tables.MEASURE.HOUSEROUND_ID.eq(houseRoundId)),
                Tables.MEASURE.ID, Tables.MEASURETYPE.NAME)
        .setRequired()
        .setInitialValue(measure.getMeasuretypeId(), 0)
        .setLabel("Measure type"))
.addEntry(new TableEntryPickRecord(Tables.MEASURE.PLAYERROUND_ID)
        .setPickTable(data, Tables.MEASURE.join(Tables.PLAYERROUND)
                .on(Tables.MEASURE.PLAYERROUND_ID.eq(Tables.PLAYERROUND.ID))
                .and(Tables.MEASURE.HOUSEROUND_ID.eq(houseRoundId))
                .join(Tables.PLAYER).on(Tables.PLAYERROUND.PLAYER_ID.eq(Tables.PLAYER.ID)),
                Tables.MEASURE.ID, Tables.PLAYER.CODE)
        .setRequired()
        .setInitialValue(measure.getMeasuretypeId(), 0)
        .setLabel("Player"))
averbraeck commented 9 months ago

In the end, the selection of a house_id for the houseround table was simplified by using a direct SQL query:

.addEntry(new TableEntryPickRecord(Tables.HOUSEROUND.HOUSE_ID).setPickTable(data,
    dslContext.fetch("SELECT * from HOUSE INNER JOIN community ON house.community_id = community.id "
        + "WHERE community.gameversion_id = " + gameSession.getGameversionId()
        + " AND house.available_round <= " + groupRound.getRoundNumber()),
        Tables.HOUSE.ID, Tables.HOUSE.CODE)
averbraeck commented 9 months ago

Admin app adapted to changes.