Skip to content

Commit

Permalink
feat: remove public stats EddieHubCommunity#4641 (EddieHubCommunity#4642
Browse files Browse the repository at this point in the history
)

* feat: remove public stats EddieHubCommunity#4641

* fix test & update shard count

* fix: homepage screenshots

---------

Co-authored-by: Dan <[email protected]>
  • Loading branch information
eddiejaoude and dan-mba authored Feb 10, 2023
1 parent 5157bf3 commit 9f33866
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 427 deletions.
1 change: 0 additions & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ LINKFREE_MONGO_CONNECTION_STRING="mongodb://mongodb:27017/linkfree"
NEXT_PUBLIC_GA_MEASUREMENT_ID=""
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
NODE_ENV="development"
SHADOWBAN=""

GITHUB_ID=""
GITHUB_SECRET=""
Expand Down
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ LINKFREE_MONGO_CONNECTION_STRING="mongodb://localhost:27017/linkfree"
NEXT_PUBLIC_GA_MEASUREMENT_ID=""
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
NODE_ENV="development"
SHADOWBAN=""

GITHUB_ID=""
GITHUB_SECRET=""
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
shardIndex: [1, 2, 3]
shardTotal: [3]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
13 changes: 8 additions & 5 deletions components/navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export default function Navbar() {
}, [isOpen]);

const primary = [
{
name: "Discover",
url: "/discover",
},
{
name: "Search",
url: "/search",
Expand Down Expand Up @@ -171,7 +167,14 @@ export default function Navbar() {
</div>
</div>

<div className={`${isOpen?"transform translate-y-0 opacity-100":"transform -translate-y-96 opacity-0 "} md:hidden z-20 absolute t-0 bg-gray-800 transition-all duration-700 ease-in-out w-full`} id="mobile-menu">
<div
className={`${
isOpen
? "transform translate-y-0 opacity-100"
: "transform -translate-y-96 opacity-0 "
} md:hidden z-20 absolute t-0 bg-gray-800 transition-all duration-700 ease-in-out w-full`}
id="mobile-menu"
>
<div className="px-2 pt-2 pb-3 space-y-1 sm:px-3">
{primary.map((item, index) => (
<NavLink
Expand Down
5 changes: 0 additions & 5 deletions components/user/UserCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export default function UserCard({ profile }) {
className="rounded-full"
fallback={profile.name}
/>
{profile.views && (
<div className="absolute inline-block top-0 right-0 bottom-auto left-auto translate-x-2/4 -translate-y-1/2 rotate-0 skew-x-0 skew-y-0 scale-x-100 scale-y-100 py-1 px-1.5 text-xs leading-none text-center whitespace-nowrap align-baseline font-bold bg-orange-600 text-black rounded-full z-10">
{abbreviateNumber(profile.views)}
</div>
)}
</div>
<div>
<h3 className="text-xl justify-center text-center mb-2 text-orange-600 font-bold">
Expand Down
8 changes: 1 addition & 7 deletions components/user/UserLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import getIcon from "../Icon";
import colors from "../../config/icons.json";
import Link from "../Link";

export default function UserLink({
BASE_URL,
link,
username,
displayStatsPublic,
}) {
export default function UserLink({ BASE_URL, link, username }) {
const [clicks, setClicks] = useState(link.clicks || 0);
const DisplayIcon = getIcon(link.icon);
let aria = "";
Expand Down Expand Up @@ -37,7 +32,6 @@ export default function UserLink({
<DisplayIcon aria-label={`${aria} icon`} />
</span>
<span className="grow">{link.name}</span>
{displayStatsPublic && <span>{clicks}</span>}
</Link>
);
}
1 change: 0 additions & 1 deletion components/user/UserLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default function UserLinks({ BASE_URL, data }) {
key={link.id}
link={link}
username={data.username}
displayStatsPublic={data.displayStatsPublic}
/>
))}
</div>
Expand Down
8 changes: 0 additions & 8 deletions components/user/UserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ export default function UserProfile({ BASE_URL, data }) {
<>
<div className="flex justify-center items-center flex-col md:flex-row gap-x-6">
<div className="inline-flex relative w-fit">
{data.displayStatsPublic && (
<div
id="profile-views"
className="absolute inline-block top-0 right-0 bottom-auto left-auto translate-x-2/4 -translate-y-1/2 rotate-0 skew-x-0 skew-y-0 scale-x-100 scale-y-100 py-1 px-1.5 text-xs leading-none text-center whitespace-nowrap align-baseline font-bold bg-orange-600 text-black rounded-full z-10"
>
{abbreviateNumber(data.views)}
</div>
)}
<FallbackImage
src={`https://github.com/${data.username}.png`}
alt={`Profile picture of ${data.name}`}
Expand Down
36 changes: 0 additions & 36 deletions pages/api/discover/popular.js

This file was deleted.

5 changes: 1 addition & 4 deletions pages/api/discover/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export default async function handler(req, res) {

let profiles = [];
try {
profiles = await Profile.aggregate([
{ $sample: { size: 5 } },
{ $match: { username: { $nin: process.env.SHADOWBAN.split(",") } } },
]);
profiles = await Profile.aggregate([{ $sample: { size: 5 } }]);
} catch (e) {
logger.error(e, "failed to load profiles");
}
Expand Down
58 changes: 0 additions & 58 deletions pages/api/discover/trending.js

This file was deleted.

26 changes: 1 addition & 25 deletions pages/api/users/[username]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,5 @@ export default async function handler(req, res) {
}
}

if (!data.displayStatsPublic) {
return res.status(200).json({ username, ...data });
}

const latestProfile = await Profile.findOne({ username });
const links = await Link.find({ profile: latestProfile._id });

const profileWithStats = {
username,
...data,
views: latestProfile.views,
links: data.links.map((link) => {
const statFound = links.find((linkStats) => linkStats.url === link.url);
if (statFound) {
return {
...link,
clicks: statFound.clicks,
};
}

return link;
}),
};

res.status(200).json(profileWithStats);
return res.status(200).json({ username, ...data });
}
4 changes: 1 addition & 3 deletions pages/api/users/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import findAllBasic from "../../../services/profiles/findAllBasic";
import hydrateWithStats from "../../../services/profiles/hydrateWithStats";

export default async function handler(req, res) {
if (req.method != "GET") {
Expand All @@ -9,7 +8,6 @@ export default async function handler(req, res) {
}

const profiles = findAllBasic();
const profilesWithStats = await hydrateWithStats(profiles);

res.status(200).json(profilesWithStats);
res.status(200).json(profiles);
}
121 changes: 0 additions & 121 deletions pages/discover.js

This file was deleted.

1 change: 0 additions & 1 deletion pages/docs/full-profile-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ _Note: the data fields `links`, `milestones`, `testimonials`, `tags`, `socials`
{
"name": "Eddie Jaoude",
"type": "personal",
"displayStatsPublic": true,
"bio": "Open Source DevRel | Founder of **EddieHub** | **GitHub** Star",
"tags": [
"Open Source",
Expand Down
Loading

0 comments on commit 9f33866

Please sign in to comment.