Repository: open-sauced/app (ts)

Issue:
Bug: contributor list "Most used languages" is innacurate
### Describe the bug

I've seen a few instances where "Most used langauages" in the contributor lists is inaccurate.

This screenshot is off of beta:

![Screenshot 2023-12-07 at 10 07 09 AM](https://github.com/open-sauced/app/assets/23109390/e662507f-4104-45a1-8418-2032979d9c22)

For example, I haven't written CSS in forever. And "Docker" isn't really a language. I'd expect this to more closely reflect what's in my user profile (TS, and Go):

![Screenshot 2023-12-07 at 10 09 33 AM](https://github.com/open-sauced/app/assets/23109390/f7eb02d4-5732-4cd7-bbd3-985627ab8b87)

---

Another thing you'll notice: @OgDev-01 has "golang, hacktoberfest" as languages. "hacktoberfest" isn't a programming language so there's something not quite right in there.

---

This, to me, looks like an ordering problem when we get `contributor.languages`. From the API against my own user, this is what's returned:

```
  "languages": {
    "Go": 601455,
    "CSS": 1391,
    "Lua": 5058,
    "Zig": 4320,
    "HTML": 4769,
    "Just": 24,
    "Rust": 7989,
    "Shell": 5566,
    "Python": 616,
    "Makefile": 2520,
    "Dockerfile": 701,
    "JavaScript": 24295,
    "TypeScript": 1393265
  },
```

which is _not_ ordered by the weights when returned from the API. We probably need to apply ordering in this chunk to ensure we get the actual top languages, not just the random first 2:

https://github.com/open-sauced/app/blob/ae560f8b51db10e2cf7ef277538a8df40f1dd616/lib/utils/contributor-utils.ts#L1-L10

But this is just a hunch, there's something that's not quite right when getting these languages.

### Steps to reproduce

1. Go to a big user list of contributors
2. Notice the most used languages
3. Go to profiles for those users
4. Notice the difference

### Browsers

Firefox

### Additional context (Is this in dev or production?)

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Contributing Docs

- [X] I agree to follow this project's Contribution Docs

Pull request:
fix: now interests are not fallbacks for most used languages
## Description

Interests are no longer fallbacks for a user's most languages as interests aren't necessarily languages, e.g. Hacktoberfest. As well aside from Hacktoberfest, the other interests are languages, but it's not reflective of someone's most used languages.

## What type of PR is this? (check all applicable)

- [ ] 🍕 Feature
- [x] 🐛 Bug Fix
- [ ] 📝 Documentation Update
- [ ] 🎨 Style
- [ ] 🧑‍💻 Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore (Release)
- [ ] ⏩ Revert

## Related Tickets & Documents

Fixes #2281

## Mobile & Desktop Screenshots/Recordings

<!-- Visual changes require screenshots -->


## Steps to QA

1. You need to be logged in
2. Ensure you have no interests set in your user settings, https://deploy-preview-2373--oss-insights.netlify.app/user/settings

![CleanShot 2023-12-18 at 20 09 11](https://github.com/open-sauced/app/assets/833231/ca6a27b4-a7e2-499f-a573-82277b6ca98e)
3. Go to a grid that you're in like a list's contributor tab. If you're not in the grid, add yourself in a test list.

This is actually hard to test as most people will have languages already, so the fallback will not kick in. 🤔 Maybe the unit tests are enough for this. 


## Added to documentation?

- [ ] 📜 README.md
- [ ] 📓 docs.opensauced.pizza
- [ ] 🍕 dev.to/opensauced
- [ ] 📕 storybook
- [x] 🙅 no documentation needed

## [optional] Are there any post-deployment tasks we need to perform?



## [optional] What gif best describes this PR or how it makes you feel?

<img src="https://media4.giphy.com/media/3og0IN2YJFptu9DQAw/giphy-downsized-medium.gif"/>

<!-- note: PRs with deleted sections will be marked invalid -->

<!--
  For Work In Progress Pull Requests, please use the Draft PR feature,
  see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details.
  
  For a timely review/response, please avoid force-pushing additional
  commits if your PR already received reviews or comments.
  
  Before submitting a Pull Request, please ensure you've done the following:
  - 📖 Read the Open Sauced Contributing Guide: https://github.com/open-sauced/.github/blob/main/CONTRIBUTING.md.
  - 📖 Read the Open Sauced Code of Conduct: https://github.com/open-sauced/.github/blob/main/CODE_OF_CONDUCT.md.
  - 👷‍♀️ Create small PRs. In most cases, this will be possible.
  - ✅ Provide tests for your changes.
  - 📝 Use descriptive commit messages.
  - 📗 Update any related documentation and include any relevant screenshots.
-->


Patch:
diff --git a/components/molecules/ContributorListTableRow/contributor-list-table-row.tsx b/components/molecules/ContributorListTableRow/contributor-list-table-row.tsx
index f1bc9976..362f4da7 100644
--- a/components/molecules/ContributorListTableRow/contributor-list-table-row.tsx
+++ b/components/molecules/ContributorListTableRow/contributor-list-table-row.tsx
@@ -158,11 +158,13 @@ const ContributorListTableRow = ({
 
           <div className="flex items-center justify-between py-3 border-b">
             <div>Languages</div>
-            {contributorLanguageList && (
-              <p>
+            {contributorLanguageList.length > 0 ? (
+              <div>
                 {firstContributorLanguage && getLanguageAbbreviation(firstContributorLanguage)}
                 {secondContributorLanguage && `, ${getLanguageAbbreviation(secondContributorLanguage)}`}
-              </p>
+              </div>
+            ) : (
+              <div>-</div>
             )}
           </div>
           <div className="flex items-center justify-between py-3 border-b">
diff --git a/lib/utils/contributor-utils.ts b/lib/utils/contributor-utils.ts
index 3ce64b77..91a5f29d 100644
--- a/lib/utils/contributor-utils.ts
+++ b/lib/utils/contributor-utils.ts
@@ -1,10 +1,6 @@
 export function getTopContributorLanguages(contributor: DbUser) {
-  // some contributors will have empty language objects so we will pull their popular language from the interests field instead of defaulting to nothing
-  const entries = Object.entries<string>(contributor.languages);
-  const languages =
-    entries.length > 0
-      ? entries.map(([language]) => language)
-      : contributor.interests.split(",").filter((interest) => interest !== "");
+  // Note that it's possible for a user to have no languages
+  const languages = Object.entries(contributor.languages).map(([language]) => language);
 
   return languages.sort((a, b) => (a < b ? -1 : 1)).slice(0, 2);
 }


Test patch:
diff --git a/lib/utils/contributor-utils.test.ts b/lib/utils/contributor-utils.test.ts
index 4f644614..20f5ffcb 100644
--- a/lib/utils/contributor-utils.test.ts
+++ b/lib/utils/contributor-utils.test.ts
@@ -36,6 +36,7 @@ describe("contributor utilities", () => {
       is_maintainer: true,
       coupon_code: "DBUSER10",
       receive_product_updates: true,
+      interests: "Ultimate Frisbee, Hiking, Biking, C++",
     });
 
     it("should get the top two languages in alpabetical order", () => {
@@ -47,25 +48,14 @@ describe("contributor utilities", () => {
           rust: 4,
           go: 5,
         },
-        interests: "logo,c++,assembly",
       }) satisfies DbUser;
 
       expect(getTopContributorLanguages(user)).toEqual(["go", "javascript"]);
     });
 
-    it("should get the top two languages in alpabetical order as the top two interests when there are no languages", () => {
+    it("should get no languages when there are no languages", () => {
       const user = Object.assign({}, baseUser, {
         languages: {},
-        interests: "logo,c++,assembly",
-      }) satisfies DbUser;
-
-      expect(getTopContributorLanguages(user)).toEqual(["assembly", "c++"]);
-    });
-
-    it("should get no languages when there are no languages or interests", () => {
-      const user = Object.assign({}, baseUser, {
-        languages: {},
-        interests: "",
       }) satisfies DbUser;
 
       expect(getTopContributorLanguages(user)).toEqual([]);