Skip to content

Commit

Permalink
refactor(msar): Consistent terminology (session vs. api)
Browse files Browse the repository at this point in the history
  • Loading branch information
battis committed Jan 2, 2025
1 parent baaf6cd commit e12e273
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
5 changes: 5 additions & 0 deletions packages/msar/src/workflows/Snapshot/Area/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ export class StudentDataError extends Error {
public message = 'Student data is not included in this snapshot';
}

/*
* FIXME add session to Area.Base.Options
* Should be able to invoke endpoints on specific session
*/
export type Options = {
groupId: number;
payload?: types.datadirect.ContentItem.Payload;
ignoreErrors?: boolean;
studentData?: boolean;
Expand Down
49 changes: 27 additions & 22 deletions packages/msar/src/workflows/Snapshot/Area/Topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function getPossibleContent() {

export const snapshot: Base.Snapshot<Data> = async ({
groupId: Id,
payload = { format: 'json' },
payload,
ignoreErrors = true,
studentData
}): Promise<Data | undefined> => {
Expand All @@ -38,11 +38,13 @@ export const snapshot: Base.Snapshot<Data> = async ({
await getPossibleContent();
const topics = await api.datadirect.sectiontopicsget({
payload: {
format: 'json',
sharedTopics: true,
future: !!payload.future,
expired: !!payload.expired,
active: !!payload.active
// TODO Fix typing to avoid parameter redundancy
active: true,
future: true,
expired: true,
...payload,
format: 'json', // TODO Empirically, `format` is often optional
sharedTopics: true // TODO sharedTopics should be configurable
},
pathParams: { Id }
});
Expand Down Expand Up @@ -83,22 +85,25 @@ export const snapshot: Base.Snapshot<Data> = async ({
const entry: Item = {
...item,
ObjectType,
Content: await (
await api.datadirect.TopicContent_detail(item, possibleContent!)
)({
payload: {
...payload,
id: TopicID,
leadSectionId: Id,
contextValue: Id,
topicIndexId: TopicID,
contentIndexId: topic.TopicIndexID,
row: item.RowIndex,
column: item.ColumnIndex,
cell: item.CellIndex
},
pathParams: { Id }
})
Content: await api.datadirect.TopicContent_detail(
item,
possibleContent!,
{
payload: {
format: 'json',
...payload,
id: TopicID,
leadSectionId: Id,
contextValue: Id,
topicIndexId: TopicID,
contentIndexId: topic.TopicIndexID,
row: item.RowIndex,
column: item.ColumnIndex,
cell: item.CellIndex
},
pathParams: { Id }
}
)
};
if (
!studentData &&
Expand Down
2 changes: 1 addition & 1 deletion packages/msar/src/workflows/Snapshot/Manager/Single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function snapshot({

const Start = new Date();

const endpointParams = { api, groupId, options };
const endpointParams = { session, groupId, ...options };
const [SectionInfo, BulletinBoard, Topics, Assignments, Gradebook] =
await Promise.all([
Area.SectionInfo.snapshot(endpointParams),
Expand Down

0 comments on commit e12e273

Please sign in to comment.