Skip to content

Commit

Permalink
Bugfix, Release v2.1.1: Work position order (#38)
Browse files Browse the repository at this point in the history
 - Fixes #38
 - New Dash endpoint does *not* return work positions in correct order,
 so methods that were looking up elements by type instead of accessing
 via Table-of-Contents (which preserves order in arrays), were getting
 entities back in the correct order (was actually completely reversed
 for some endpoints!)
 - Fix is to switch to always looking up entities by ToC, for both API
 response types, to make sure work position order is always preserved
 - This affects both regular JSON Resume and vCard export, although I
 believe the issue filed was in reference to vCard specifically
  • Loading branch information
joshuatz committed Dec 19, 2020
1 parent 1ed8b7d commit 986da39
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ When in doubt, refresh the profile page before using this tool.
## Updates:
Date | Release | Notes
--- | --- | ---
12/19/2020 | 2.1.1 | Fix: Ordering of work history with new API endpoint ([#38](https://github.com/joshuatz/linkedin-to-jsonresume/issues/38))
12/7/2020 | 2.1.0 | Fix: Issue with multilingual profile, when exporting your own profile with a different locale than your profile's default. ([#37](https://github.com/joshuatz/linkedin-to-jsonresume/pull/37))
11/12/2020 | 2.0.0 | Support for multiple schema versions ✨ ([#34](https://github.com/joshuatz/linkedin-to-jsonresume/pull/34))
11/8/2020 | 1.5.1 | Fix: Omit partial BDAY export in vCard ([#32](https://github.com/joshuatz/linkedin-to-jsonresume/issues/32))
Expand Down Expand Up @@ -136,6 +137,16 @@ li2jr.parseAndShowOutput();
If you do want to find the actual injected code of the extension in Chrome dev tools, you should be able to find it under `Sources -> Content Scripts -> top -> JSON Resume Exporter -> {main.js}`

#### Debugging Snippets
Helpful snippets (subject to change; these rely heavily on internals):

```js
// Get main profileDB (after running extension)
var profileRes = await li2JrInstance.getParsedProfile();
var profileDb = await li2JrInstance.internals.buildDbFromLiSchema(profileRes.liResponse);

```

---

## DISCLAIMER:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkedin-to-json-resume-exporter",
"version": "2.1.0",
"version": "2.1.1",
"description": "Browser tool to grab details from your open LinkedIn profile page and export to JSON Resume Schema",
"private": true,
"main": "src/main.js",
Expand Down
10 changes: 6 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ window.LinkedinToResumeJson = (() => {
});
};
/**
* Get all elements that match type. Should usually just be one
* Get all elements that match type.
* WARNING: Since this gets elements directly by simply iterating through all results, not via ToC, order of entities returned is simply whatever order LI provides them in the response. Not guaranteed to be in order! Use a ToC approach if you need ordered results.
* @param {string | string[]} typeStr - Type, e.g. `$com.linkedin...`
* @returns {LiEntity[]}
*/
Expand Down Expand Up @@ -368,7 +369,8 @@ window.LinkedinToResumeJson = (() => {
}
// To make this easier to work with lookup, we'll unpack the
// profile view nested object BACK into the root (ToC), so
// that lookups can be performed by key instead of type | recipe
// that subsequent lookups can be performed by key instead of type | recipe
// This is critical for lookups that require precise ordering, preserved by ToCs
/** @type {LiResponse} */
const hoistedRes = {
data: {
Expand Down Expand Up @@ -504,7 +506,7 @@ window.LinkedinToResumeJson = (() => {
allWorkCanBeCaptured = paging.start + paging.count >= paging.total;
}
if (allWorkCanBeCaptured) {
const workPositions = db.getElementsByType(_liTypeMappings.workPositions.types);
const workPositions = db.getValuesByKey(_liTypeMappings.workPositions.tocKeys);
workPositions.forEach((position) => {
parseAndPushPosition(position, db);
});
Expand Down Expand Up @@ -1573,7 +1575,7 @@ window.LinkedinToResumeJson = (() => {
}
}
// Try to get currently employed organization
const positions = profileDb.getElementsByType(_liTypeMappings.workPositions.types);
const positions = profileDb.getValuesByKey(_liTypeMappings.workPositions.tocKeys);
if (positions.length) {
vCard.organization = positions[0].companyName;
vCard.title = positions[0].title;
Expand Down

0 comments on commit 986da39

Please sign in to comment.