Skip to content

Commit 986da39

Browse files
committed
Bugfix, Release v2.1.1: Work position order (#38)
- 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
1 parent 1ed8b7d commit 986da39

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ When in doubt, refresh the profile page before using this tool.
7373
## Updates:
7474
Date | Release | Notes
7575
--- | --- | ---
76+
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))
7677
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))
7778
11/12/2020 | 2.0.0 | Support for multiple schema versions ✨ ([#34](https://github.com/joshuatz/linkedin-to-jsonresume/pull/34))
7879
11/8/2020 | 1.5.1 | Fix: Omit partial BDAY export in vCard ([#32](https://github.com/joshuatz/linkedin-to-jsonresume/issues/32))
@@ -136,6 +137,16 @@ li2jr.parseAndShowOutput();
136137
137138
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}`
138139

140+
#### Debugging Snippets
141+
Helpful snippets (subject to change; these rely heavily on internals):
142+
143+
```js
144+
// Get main profileDB (after running extension)
145+
var profileRes = await li2JrInstance.getParsedProfile();
146+
var profileDb = await li2JrInstance.internals.buildDbFromLiSchema(profileRes.liResponse);
147+
148+
```
149+
139150
---
140151

141152
## DISCLAIMER:

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linkedin-to-json-resume-exporter",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Browser tool to grab details from your open LinkedIn profile page and export to JSON Resume Schema",
55
"private": true,
66
"main": "src/main.js",

src/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ window.LinkedinToResumeJson = (() => {
114114
});
115115
};
116116
/**
117-
* Get all elements that match type. Should usually just be one
117+
* Get all elements that match type.
118+
* 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.
118119
* @param {string | string[]} typeStr - Type, e.g. `$com.linkedin...`
119120
* @returns {LiEntity[]}
120121
*/
@@ -368,7 +369,8 @@ window.LinkedinToResumeJson = (() => {
368369
}
369370
// To make this easier to work with lookup, we'll unpack the
370371
// profile view nested object BACK into the root (ToC), so
371-
// that lookups can be performed by key instead of type | recipe
372+
// that subsequent lookups can be performed by key instead of type | recipe
373+
// This is critical for lookups that require precise ordering, preserved by ToCs
372374
/** @type {LiResponse} */
373375
const hoistedRes = {
374376
data: {
@@ -504,7 +506,7 @@ window.LinkedinToResumeJson = (() => {
504506
allWorkCanBeCaptured = paging.start + paging.count >= paging.total;
505507
}
506508
if (allWorkCanBeCaptured) {
507-
const workPositions = db.getElementsByType(_liTypeMappings.workPositions.types);
509+
const workPositions = db.getValuesByKey(_liTypeMappings.workPositions.tocKeys);
508510
workPositions.forEach((position) => {
509511
parseAndPushPosition(position, db);
510512
});
@@ -1573,7 +1575,7 @@ window.LinkedinToResumeJson = (() => {
15731575
}
15741576
}
15751577
// Try to get currently employed organization
1576-
const positions = profileDb.getElementsByType(_liTypeMappings.workPositions.types);
1578+
const positions = profileDb.getValuesByKey(_liTypeMappings.workPositions.tocKeys);
15771579
if (positions.length) {
15781580
vCard.organization = positions[0].companyName;
15791581
vCard.title = positions[0].title;

0 commit comments

Comments
 (0)