Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bf9aee6
WIP: move executeAction() from PerspectiveProxy into executor: Perspe…
lucksus May 22, 2024
9a36762
Enable non-string parameters and handle serde_json::Value
lucksus May 22, 2024
e7782e9
Declare `parameters` as nullable
lucksus May 22, 2024
020e308
feat: Add createSubject method to PerspectiveClient
fayeed May 23, 2024
54ef86a
chore: Remove unnecessary code in SubjectRepository.ts
fayeed May 23, 2024
546f086
feat: Add getSubjectData method to PerspectiveClient and PerspectiveP…
fayeed May 23, 2024
e2b7225
feat: Add perspective_get_subject_data mutation resolver
fayeed May 23, 2024
10cb1be
Merge branch 'notifications' into subject-performance
lucksus May 23, 2024
a798c7f
Fix new create_subject() function with json5 crate to parse non-JSON …
lucksus May 23, 2024
fd9630d
Remove debug logs
lucksus May 23, 2024
ea9089b
Merge branch 'dev' into subject-performance
lucksus May 23, 2024
d0ea6fc
Fixed compilation of new PerspectiveInstance::get_subject_data() func…
lucksus May 23, 2024
b4b8a10
Merge commit 'ea9089bdd1135a3af331460ed54c29bbefdf3ce8' into subject-…
lucksus May 23, 2024
e280614
Use new get_subject_data query in SubjectEntity
lucksus May 23, 2024
130e56d
Expect List results from collection prolog query
lucksus May 23, 2024
021d462
Fix JSON serialization in get_subject_data
lucksus May 23, 2024
4926062
Test resolveLanguage works with SubjectEntity
lucksus May 23, 2024
6e4f1fd
WIP Implement resolveLanguage for SubjectEntity
lucksus May 23, 2024
feed4ba
chore: Update PerspectiveInstance to include ExpressionRendered in gr…
fayeed May 24, 2024
a91eb64
chore: Remove unnecessary calls to ensureSubject in SubjectRepository
fayeed May 24, 2024
412d659
changelog
lucksus May 24, 2024
9d01e12
Merge branch 'subject-performance' of github.com:perspect3vism/ad4m-e…
fayeed May 24, 2024
6a47221
refactor: Improve data retrieval in SubjectRepository
fayeed May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project _loosely_ adheres to [Semantic Versioning](https://semver.org/spec/

### Changed
- Partially migrated the Runtime service to Rust. (DM language installation for agents is pending.) [PR#466](https://github.com/coasys/ad4m/pull/466)
- Improved performance of SDNA / SubjectClass functions by moving code from client into executor and saving a lot of client <-> executor roundtrips [PR#480](https://github.com/coasys/ad4m/pull/480)


## [0.9.0] - 23/03/2024
Expand Down
50 changes: 48 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 15 additions & 27 deletions ad4m-hooks/helpers/src/factory/SubjectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async update(id: string, data: QueryPartialEntity<SubjectClass>) {
await this.ensureSubject();

const instance = await this.get(id);

if (!instance) {
Expand Down Expand Up @@ -102,8 +100,8 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async get(id: string): Promise<SubjectClass | null> {
await this.ensureSubject();
if (id) {
await this.ensureSubject();
const subjectProxy = await this.perspective.getSubjectProxy(
id,
this.subject
Expand All @@ -118,7 +116,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async getData(id: string): Promise<SubjectClass | string | null> {
await this.ensureSubject();
const entry = await this.get(id);
if (entry) {
// @ts-ignore
Expand All @@ -133,28 +130,21 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
new LinkQuery({ source: entry.baseExpression })
);

const getters = Object.entries(Object.getOwnPropertyDescriptors(entry))
.filter(([key, descriptor]) => typeof descriptor.get === "function")
.map(([key]) => key);

const promises = getters.map((getter) => entry[getter]);
return Promise.all(promises).then((values) => {
return getters.reduce((acc, getter, index) => {
let value = values[index];
if (this.tempSubject.prototype?.__properties[getter]?.transform) {
value =
this.tempSubject.prototype.__properties[getter].transform(value);
}
let data: any = await this.perspective.getSubjectData(this.subject, entry.baseExpression)

return {
...acc,
id: entry.baseExpression,
timestamp: links[0].timestamp,
author: links[0].author,
[getter]: value,
};
}, {});
});
for (const key in data) {
if (this.tempSubject.prototype?.__properties[key]?.transform) {
data[key] =
this.tempSubject.prototype.__properties[key].transform(data[key]);
}
}

return {
id: entry.baseExpression,
timestamp: links[0].timestamp,
author: links[0].author,
...data,
}
}

async getAll(source?: string, query?: QueryOptions): Promise<SubjectClass[]> {
Expand Down Expand Up @@ -232,8 +222,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
source?: string,
query?: QueryOptions
): Promise<SubjectClass[]> {
await this.ensureSubject();

const subjects = await this.getAll(source, query);

const entries = await Promise.all(
Expand Down
Loading