Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
324 changes: 162 additions & 162 deletions .yarn/releases/yarn-4.4.1.cjs → .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.4.1.cjs
yarnPath: .yarn/releases/yarn-4.5.0.cjs

# https://github.com/vitejs/vite-plugin-react-swc/issues/74#issuecomment-1520484130
# https://github.com/swc-project/swc/issues/5616#issuecomment-1265639797
Expand Down
15 changes: 15 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Release Notes
=============

Version 0.21.2 (Released October 10, 2024)
--------------

- Content File Score Adjustment (#1667)
- remove unnecessary padding adjustment on Input base styles (#1666)

Version 0.21.1 (Released October 09, 2024)
--------------

- Always delete past events during ETL, and filter them out from api results too just in case (#1660)
- Add location field to LearningResource and LearningResourceRun models (#1604)
- Cached department and topic page counts (#1661)
- Shanbady/randomize featured resources (#1653)
- Ignore NotFoundErrors in switch_indices function (#1654)

Version 0.21.0 (Released October 07, 2024)
--------------

Expand Down
12 changes: 12 additions & 0 deletions frontends/api/src/generated/v0/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,18 @@ export interface ProgramCertificate {
* @memberof ProgramCertificate
*/
record_hash: string
/**
*
* @type {string}
* @memberof ProgramCertificate
*/
program_letter_generate_url: string
/**
*
* @type {string}
* @memberof ProgramCertificate
*/
program_letter_share_url: string
/**
*
* @type {string}
Expand Down
196 changes: 196 additions & 0 deletions frontends/api/src/generated/v1/api.ts

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions frontends/api/src/hooks/learningResources/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe("LearningPath CRUD", () => {
}

test("useLearningpathCreate calls correct API", async () => {
const { path, pathUrls, keys } = makeData()
const { path, pathUrls } = makeData()
const url = pathUrls.list

const requestData = { title: path.title }
Expand All @@ -226,9 +226,12 @@ describe("LearningPath CRUD", () => {

await waitFor(() => expect(result.current.isSuccess).toBe(true))
expect(makeRequest).toHaveBeenCalledWith("post", url, requestData)
expect(queryClient.invalidateQueries).toHaveBeenCalledWith(
keys.learningResources,
)
expect(queryClient.invalidateQueries).toHaveBeenCalledWith([
"learningResources",
"learningpaths",
"learning_paths",
"list",
])
})

test("useLearningpathDestroy calls correct API", async () => {
Expand Down
38 changes: 32 additions & 6 deletions frontends/api/src/hooks/learningResources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import learningResources, {
invalidateResourceWithUserListQueries,
updateListParentsOnAdd,
updateListParentsOnDestroy,
updateListParents,
} from "./keyFactory"
import { ListType } from "../../common/constants"

Expand All @@ -62,6 +63,16 @@ const useFeaturedLearningResourcesList = (params: FeaturedListParams = {}) => {
return useQuery(learningResources.featured(params))
}

const useLearningResourceTopic = (
id: number,
opts: Pick<UseQueryOptions, "enabled"> = {},
) => {
return useQuery({
...learningResources.topic(id),
...opts,
})
}

const useLearningResourceTopics = (
params: TopicsListRequest = {},
opts: Pick<UseQueryOptions, "enabled"> = {},
Expand Down Expand Up @@ -113,9 +124,9 @@ const useLearningpathCreate = () => {
LearningPathResourceRequest: params,
}),
onSettled: () => {
// Invalidate everything: this is over-aggressive, but the new resource
// could appear in most lists
queryClient.invalidateQueries(learningResources._def)
queryClient.invalidateQueries(
learningResources.learningpaths._ctx.list._def,
)
},
})
}
Expand Down Expand Up @@ -333,12 +344,19 @@ const useLearningResourceSetUserListRelationships = () => {
) => learningResourcesApi.learningResourcesUserlistsPartialUpdate(params),
onSettled: (_response, _err, vars) => {
invalidateResourceQueries(queryClient, vars.id, {
skipFeatured: false,
skipFeatured: true,
})
vars.userlist_id?.forEach((userlistId) => {
invalidateUserListQueries(queryClient, userlistId)
})
},
onSuccess: (response, vars) => {
queryClient.setQueriesData<PaginatedLearningResourceList>(
learningResources.featured({}).queryKey,
(featured) =>
updateListParents(vars.id, featured, response.data, "userlist"),
)
},
})
}

Expand All @@ -351,14 +369,21 @@ const useLearningResourceSetLearningPathRelationships = () => {
learningResourcesApi.learningResourcesLearningPathsPartialUpdate(params),
onSettled: (_response, _err, vars) => {
invalidateResourceQueries(queryClient, vars.id, {
skipFeatured: false,
skipFeatured: true,
})
vars.learning_path_id?.forEach((learningPathId) => {
invalidateResourceQueries(queryClient, learningPathId, {
skipFeatured: false,
skipFeatured: true,
})
})
},
onSuccess: (response, vars) => {
queryClient.setQueriesData<PaginatedLearningResourceList>(
learningResources.featured({}).queryKey,
(featured) =>
updateListParents(vars.id, featured, response.data, "learningpath"),
)
},
})
}

Expand Down Expand Up @@ -486,6 +511,7 @@ export {
useLearningResourcesList,
useFeaturedLearningResourcesList,
useLearningResourcesDetail,
useLearningResourceTopic,
useLearningResourceTopics,
useLearningPathsList,
useLearningPathsDetail,
Expand Down
41 changes: 41 additions & 0 deletions frontends/api/src/hooks/learningResources/keyFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const learningResources = createQueryKeys("learningResources", {
})
},
}),
topic: (id: number | undefined) => ({
queryKey: [id],
queryFn: () =>
id ? topicsApi.topicsRetrieve({ id }).then((res) => res.data) : null,
}),
topics: (params: TopicsListRequest) => ({
queryKey: [params],
queryFn: () => topicsApi.topicsList(params).then((res) => res.data),
Expand Down Expand Up @@ -366,11 +371,47 @@ const updateListParentsOnDestroy = (
}
}

/**
* Given
* - a LearningResource ID
* - a paginated list of current resources
* - a list of new relationships
* - the type of list
* Update the resources' user_list_parents field to include the new relationships
*/
const updateListParents = (
resourceId: number,
staleResources?: PaginatedLearningResourceList,
newRelationships?: MicroUserListRelationship[],
listType?: "userlist" | "learningpath",
) => {
if (!resourceId || !staleResources || !newRelationships || !listType)
return staleResources
const matchIndex = staleResources.results.findIndex(
(res) => res.id === resourceId,
)
if (matchIndex === -1) return staleResources
const updatedResults = [...staleResources.results]
const newResource = { ...updatedResults[matchIndex] }
if (listType === "userlist") {
newResource.user_list_parents = newRelationships
}
if (listType === "learningpath") {
newResource.learning_path_parents = newRelationships
}
updatedResults[matchIndex] = newResource
return {
...staleResources,
results: updatedResults,
}
}

export default learningResources
export {
invalidateResourceQueries,
invalidateUserListQueries,
invalidateResourceWithUserListQueries,
updateListParentsOnAdd,
updateListParentsOnDestroy,
updateListParents,
}
7 changes: 6 additions & 1 deletion frontends/api/src/test-utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const query = (params: any) => {
const queryString = new URLSearchParams()
for (const [key, value] of Object.entries(params)) {
if (Array.isArray(value)) {
value.forEach((v) => queryString.append(key, String(v)))
if (value.length === 0) {
queryString.append(key, "")
} else {
value.forEach((v) => queryString.append(key, String(v)))
}
} else {
queryString.append(key, String(value))
}
Expand Down Expand Up @@ -96,6 +100,7 @@ const platforms = {
}

const topics = {
get: (id: number) => `${API_BASE_URL}/api/v1/topics/${id}/`,
list: (params?: Params<TopicsApi, "topicsList">) =>
`${API_BASE_URL}/api/v1/topics/${query(params)}`,
}
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading