[fix] repository:calendar
This commit is contained in:
parent
2c019723bf
commit
4733260de1
|
|
@ -41,6 +41,14 @@ namespace _zeitbild.repository.calendar
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_access_attributed_group_preview = {
|
||||||
|
group_id : int;
|
||||||
|
level : int;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_access_attributed_user_row = {
|
type type_access_attributed_user_row = {
|
||||||
|
|
@ -50,6 +58,14 @@ namespace _zeitbild.repository.calendar
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_access_attributed_user_preview = {
|
||||||
|
user_id : int;
|
||||||
|
level : int;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_dispersal = {
|
type type_dispersal = {
|
||||||
|
|
@ -405,16 +421,18 @@ namespace _zeitbild.repository.calendar
|
||||||
const calendar_id : _zeitbild.type_calendar_id = await core_store.create(
|
const calendar_id : _zeitbild.type_calendar_id = await core_store.create(
|
||||||
dispersal.core_row
|
dispersal.core_row
|
||||||
);
|
);
|
||||||
for await (const access_attributed_group_row of dispersal.access_attributed_group_rows) {
|
for await (const access_attributed_group_row of dispersal.access_attributed_group_rows)
|
||||||
|
{
|
||||||
get_access_attributed_group_chest().write(
|
get_access_attributed_group_chest().write(
|
||||||
[calendar_id, access_attributed_group_row["group_id"]],
|
[calendar_id, access_attributed_group_row.group_id],
|
||||||
{"level": access_attributed_group_row["level"]}
|
{"level": access_attributed_group_row.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for await (const access_attributed_user_row of dispersal.access_attributed_user_rows) {
|
for await (const access_attributed_user_row of dispersal.access_attributed_user_rows)
|
||||||
|
{
|
||||||
get_access_attributed_user_chest().write(
|
get_access_attributed_user_chest().write(
|
||||||
[calendar_id, access_attributed_user_row["user_id"]],
|
[calendar_id, access_attributed_user_row.user_id],
|
||||||
{"level": access_attributed_user_row["level"]}
|
{"level": access_attributed_user_row.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await lib_plankton.cache.clear(_zeitbild.cache_regular);
|
await lib_plankton.cache.clear(_zeitbild.cache_regular);
|
||||||
|
|
@ -441,82 +459,114 @@ namespace _zeitbild.repository.calendar
|
||||||
// attributed:group
|
// attributed:group
|
||||||
{
|
{
|
||||||
const access_attributed_group_chest = get_access_attributed_group_chest();
|
const access_attributed_group_chest = get_access_attributed_group_chest();
|
||||||
const hits : Array<Record<string, any>> = await access_attributed_group_chest.search(
|
const hits : Array<{key : Array<any>; preview : type_access_attributed_group_row;}> = (
|
||||||
|
(await access_attributed_group_chest.search(
|
||||||
{
|
{
|
||||||
"expression": "(calendar_id = $calendar_id)",
|
"expression": "(calendar_id = $calendar_id)",
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"calendar_id": calendar_id,
|
"calendar_id": calendar_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
))
|
||||||
|
.map(
|
||||||
|
hit => (
|
||||||
|
{
|
||||||
|
"key": hit.key,
|
||||||
|
"preview": {
|
||||||
|
"group_id": hit.preview["group_id"],
|
||||||
|
"level": hit.preview["level"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const contrast = lib_plankton.list.contrast<
|
const contrast = lib_plankton.list.contrast<
|
||||||
Record<string, any>,
|
{key : Array<any>; preview : type_access_attributed_group_row;},
|
||||||
Record<string, any>
|
type_access_attributed_group_row
|
||||||
>(
|
>(
|
||||||
hits,
|
hits,
|
||||||
hit => hit["group_id"],
|
hit => hit.preview.group_id.toFixed(0),
|
||||||
dispersal.access_attributed_group_rows,
|
dispersal.access_attributed_group_rows,
|
||||||
row => row["group_id"]
|
row => row.group_id.toFixed(0)
|
||||||
);
|
);
|
||||||
// delete
|
// delete
|
||||||
for await (const entry of contrast.only_left) {
|
for await (const entry of contrast.only_left)
|
||||||
|
{
|
||||||
await access_attributed_group_chest.delete(
|
await access_attributed_group_chest.delete(
|
||||||
[calendar_id, entry.left["group_id"]]
|
[calendar_id, entry.left.preview.group_id]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// update
|
// update
|
||||||
for await (const entry of contrast.both) {
|
for await (const entry of contrast.both)
|
||||||
|
{
|
||||||
await access_attributed_group_chest.write(
|
await access_attributed_group_chest.write(
|
||||||
[calendar_id, entry.right["group_id"]],
|
[calendar_id, entry.right.group_id],
|
||||||
{"level": entry.right["level"]}
|
{"level": entry.right.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// create
|
// create
|
||||||
for await (const entry of contrast.only_right) {
|
for await (const entry of contrast.only_right)
|
||||||
|
{
|
||||||
await access_attributed_group_chest.write(
|
await access_attributed_group_chest.write(
|
||||||
[calendar_id, entry.right["group_id"]],
|
[calendar_id, entry.right.group_id],
|
||||||
{"level": entry.right["level"]}
|
{"level": entry.right.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// attributed:user
|
// attributed:user
|
||||||
{
|
{
|
||||||
const access_attributed_user_chest = get_access_attributed_user_chest();
|
const access_attributed_user_chest = get_access_attributed_user_chest();
|
||||||
const hits : Array<Record<string, any>> = await access_attributed_user_chest.search(
|
const hits : Array<{key : Array<any>; preview : type_access_attributed_user_row;}> = (
|
||||||
|
(await access_attributed_user_chest.search(
|
||||||
{
|
{
|
||||||
"expression": "(calendar_id = $calendar_id)",
|
"expression": "(calendar_id = $calendar_id)",
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"calendar_id": calendar_id,
|
"calendar_id": calendar_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
))
|
||||||
|
.map(
|
||||||
|
hit => (
|
||||||
|
{
|
||||||
|
"key": hit.key,
|
||||||
|
"preview": {
|
||||||
|
"user_id": hit.preview["user_id"],
|
||||||
|
"level": hit.preview["level"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const contrast = lib_plankton.list.contrast<
|
const contrast = lib_plankton.list.contrast<
|
||||||
Record<string, any>,
|
{key : Array<any>; preview : type_access_attributed_user_row;},
|
||||||
Record<string, any>
|
type_access_attributed_user_row
|
||||||
>(
|
>(
|
||||||
hits,
|
hits,
|
||||||
hit => hit["user_id"],
|
hit => hit.preview.user_id.toFixed(0),
|
||||||
dispersal.access_attributed_user_rows,
|
dispersal.access_attributed_user_rows,
|
||||||
row => row["user_id"]
|
row => row.user_id.toFixed(0)
|
||||||
);
|
);
|
||||||
// delete
|
// delete
|
||||||
for await (const entry of contrast.only_left) {
|
for await (const entry of contrast.only_left)
|
||||||
|
{
|
||||||
await access_attributed_user_chest.delete(
|
await access_attributed_user_chest.delete(
|
||||||
[calendar_id, entry.left["user_id"]]
|
[calendar_id, entry.left.preview.user_id]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// update
|
// update
|
||||||
for await (const entry of contrast.both) {
|
for await (const entry of contrast.both)
|
||||||
|
{
|
||||||
await access_attributed_user_chest.write(
|
await access_attributed_user_chest.write(
|
||||||
[calendar_id, entry.right["user_id"]],
|
[calendar_id, entry.right.user_id],
|
||||||
{"level": entry.right["level"]}
|
{"level": entry.right.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// create
|
// create
|
||||||
for await (const entry of contrast.only_right) {
|
for await (const entry of contrast.only_right)
|
||||||
|
{
|
||||||
await access_attributed_user_chest.write(
|
await access_attributed_user_chest.write(
|
||||||
[calendar_id, entry.right["user_id"]],
|
[calendar_id, entry.right.user_id],
|
||||||
{"level": entry.right["level"]}
|
{"level": entry.right.level}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue