Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4733260de1 | ||
|
|
2c019723bf | ||
|
|
2a672381dd |
|
|
@ -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 = {
|
||||
|
|
@ -50,6 +58,14 @@ namespace _zeitbild.repository.calendar
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_access_attributed_user_preview = {
|
||||
user_id : int;
|
||||
level : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_dispersal = {
|
||||
|
|
@ -405,16 +421,18 @@ namespace _zeitbild.repository.calendar
|
|||
const calendar_id : _zeitbild.type_calendar_id = await core_store.create(
|
||||
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(
|
||||
[calendar_id, access_attributed_group_row["group_id"]],
|
||||
{"level": access_attributed_group_row["level"]}
|
||||
[calendar_id, access_attributed_group_row.group_id],
|
||||
{"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(
|
||||
[calendar_id, access_attributed_user_row["user_id"]],
|
||||
{"level": access_attributed_user_row["level"]}
|
||||
[calendar_id, access_attributed_user_row.user_id],
|
||||
{"level": access_attributed_user_row.level}
|
||||
);
|
||||
}
|
||||
await lib_plankton.cache.clear(_zeitbild.cache_regular);
|
||||
|
|
@ -441,82 +459,114 @@ namespace _zeitbild.repository.calendar
|
|||
// attributed:group
|
||||
{
|
||||
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)",
|
||||
"arguments": {
|
||||
"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<
|
||||
Record<string, any>,
|
||||
Record<string, any>
|
||||
{key : Array<any>; preview : type_access_attributed_group_row;},
|
||||
type_access_attributed_group_row
|
||||
>(
|
||||
hits,
|
||||
hit => hit["group_id"],
|
||||
hit => hit.preview.group_id.toFixed(0),
|
||||
dispersal.access_attributed_group_rows,
|
||||
row => row["group_id"]
|
||||
row => row.group_id.toFixed(0)
|
||||
);
|
||||
// delete
|
||||
for await (const entry of contrast.only_left) {
|
||||
for await (const entry of contrast.only_left)
|
||||
{
|
||||
await access_attributed_group_chest.delete(
|
||||
[calendar_id, entry.left["group_id"]]
|
||||
[calendar_id, entry.left.preview.group_id]
|
||||
);
|
||||
}
|
||||
// update
|
||||
for await (const entry of contrast.both) {
|
||||
for await (const entry of contrast.both)
|
||||
{
|
||||
await access_attributed_group_chest.write(
|
||||
[calendar_id, entry.right["group_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
[calendar_id, entry.right.group_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
// create
|
||||
for await (const entry of contrast.only_right) {
|
||||
for await (const entry of contrast.only_right)
|
||||
{
|
||||
await access_attributed_group_chest.write(
|
||||
[calendar_id, entry.right["group_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
[calendar_id, entry.right.group_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
}
|
||||
// attributed:user
|
||||
{
|
||||
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)",
|
||||
"arguments": {
|
||||
"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<
|
||||
Record<string, any>,
|
||||
Record<string, any>
|
||||
{key : Array<any>; preview : type_access_attributed_user_row;},
|
||||
type_access_attributed_user_row
|
||||
>(
|
||||
hits,
|
||||
hit => hit["user_id"],
|
||||
hit => hit.preview.user_id.toFixed(0),
|
||||
dispersal.access_attributed_user_rows,
|
||||
row => row["user_id"]
|
||||
row => row.user_id.toFixed(0)
|
||||
);
|
||||
// delete
|
||||
for await (const entry of contrast.only_left) {
|
||||
for await (const entry of contrast.only_left)
|
||||
{
|
||||
await access_attributed_user_chest.delete(
|
||||
[calendar_id, entry.left["user_id"]]
|
||||
[calendar_id, entry.left.preview.user_id]
|
||||
);
|
||||
}
|
||||
// update
|
||||
for await (const entry of contrast.both) {
|
||||
for await (const entry of contrast.both)
|
||||
{
|
||||
await access_attributed_user_chest.write(
|
||||
[calendar_id, entry.right["user_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
[calendar_id, entry.right.user_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
// create
|
||||
for await (const entry of contrast.only_right) {
|
||||
for await (const entry of contrast.only_right)
|
||||
{
|
||||
await access_attributed_user_chest.write(
|
||||
[calendar_id, entry.right["user_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
[calendar_id, entry.right.user_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue