Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release <- Main #329

Merged
merged 20 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ab4bfcf
chore: add explore how it works
Parikshit85 Apr 4, 2024
cab9d9c
Fix bug in BusinessDashboardPage component
muditmahajan Apr 17, 2024
b384c41
Refactor Services component to include pagination and status filtering
muditmahajan Apr 17, 2024
4c10d60
Merge branch 'main' of https://github.com/Build-Squad/influencer-mark…
muditmahajan Apr 17, 2024
d49fc5b
Update gunicorn command to include a timeout of 300 seconds
muditmahajan Apr 17, 2024
3100d43
Update gunicorn command to include stdbuf for line buffering
muditmahajan Apr 17, 2024
deddf3c
Update gunicorn command to include line buffering
muditmahajan Apr 18, 2024
e70d8b7
Remove pagination change in useEffect
muditmahajan Apr 18, 2024
7154a6c
chore: business profile bug fixes
Parikshit85 Apr 19, 2024
51a4b37
Merge pull request #325 from Build-Squad/ENG-242-243-Business-Profile…
Parikshit85 Apr 19, 2024
4339ff4
Merge pull request #301 from Build-Squad/ENG-209-How-it-works
Parikshit85 Apr 19, 2024
fed409c
chore:
Parikshit85 Apr 22, 2024
389b9ac
Merge pull request #323 from Build-Squad/minor-fixes-prod
varsha1305nav Apr 22, 2024
c543ddf
Add update_priority_fees function to services.py
muditmahajan Apr 22, 2024
be17d8d
Add signal to update priority fees in Configuration model
muditmahajan Apr 22, 2024
f21e750
Register signals for core applications
muditmahajan Apr 22, 2024
40bae55
Remove print statement in post_save_update_priority_fees signal
muditmahajan Apr 22, 2024
1ca8f13
chore: Amarildo's services on influencer's card bug fix
Parikshit85 Apr 22, 2024
e4a7645
Merge pull request #326 from Build-Squad/Feedback-Changes
Parikshit85 Apr 22, 2024
0486de9
Merge pull request #327 from Build-Squad/mudit/eng-234-add-validation…
varsha1305nav Apr 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
echo "Starting redis service..."
sudo systemctl start redis
echo "Starting gunicorn..."
nohup sh -c 'gunicorn -w 4 marketplace.wsgi:application > gunicorn.out 2>&1' &
nohup sh -c 'gunicorn -w 4 --access-logfile - --error-logfile - --timeout 300 marketplace.wsgi:application > gunicorn.out 2>&1' &
echo "Gunicorn started."
echo "Starting celery worker..."
nohup sh -c 'celery -A marketplace worker -l info > celery_worker.out 2>&1' &
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_prod_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo "Starting redis service..."
sudo systemctl start redis
echo "Starting gunicorn..."
nohup sh -c 'gunicorn -w 4 marketplace.wsgi:application > gunicorn.out 2>&1' &
nohup sh -c 'gunicorn -w 4 --access-logfile - --error-logfile - --timeout 300 marketplace.wsgi:application > gunicorn.out 2>&1' &
echo "Gunicorn started."
echo "Starting celery worker..."
nohup sh -c 'celery -A marketplace worker -l info > celery_worker.out 2>&1' &
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
npm install
npm run build
sudo systemctl restart nginx
pm2 stop marketplace
pm2 delete marketplace
pm2 start npm --name marketplace -- start

- name: Remove Github Actions IP from security group
Expand Down
88 changes: 47 additions & 41 deletions src/api/marketplace/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,6 @@
from django.shortcuts import get_object_or_404
from django.db.models import Avg


class BusinessAccountMetaDataSerializer(serializers.ModelSerializer):
influencer_ids = serializers.SerializerMethodField(read_only=True)
is_twitter_connected = serializers.SerializerMethodField(read_only=True)
is_wallet_connected = serializers.SerializerMethodField(read_only=True)

class Meta:
model = BusinessAccountMetaData
fields = "__all__"

def get_influencer_ids(self, business_meta_data):
completed_orders = Order.objects.filter(
buyer=business_meta_data.user_account, status="completed"
)
influencer_ids = set()

for completed_order in completed_orders:
completed_order_items = OrderItem.objects.filter(order_id=completed_order)
package_ids = completed_order_items.values_list("package_id", flat=True)
influencers = Package.objects.filter(id__in=package_ids).values_list(
"influencer_id", flat=True
)
influencer_ids.update(influencers)

return list(influencer_ids)

def get_is_twitter_connected(self, business_meta_data):
userAccount = business_meta_data.user_account
if userAccount.twitter_account:
return True
return False


def get_is_wallet_connected(self, business_meta_data):
user_wallet = Wallet.objects.filter(user_id = business_meta_data.user_account)
if(user_wallet):
return True
return False


class CategoryMasterSerializer(serializers.ModelSerializer):
class Meta:
model = CategoryMaster
Expand Down Expand Up @@ -125,7 +85,7 @@ def get_user_id(self, twitter_account):

def get_service_types(self, twitter_account):
services = Service.objects.filter(
package__influencer__twitter_account=twitter_account
package__influencer__twitter_account=twitter_account, deleted_at=None
)

# Extract service types and prices
Expand Down Expand Up @@ -268,6 +228,52 @@ def update(self, instance, validated_data):

return instance

class BusinessAccountMetaDataSerializer(serializers.ModelSerializer):
influencer_ids = serializers.SerializerMethodField(read_only=True)
is_twitter_connected = serializers.SerializerMethodField(read_only=True)
is_wallet_connected = serializers.SerializerMethodField(read_only=True)
user_twitter_profile_image = serializers.SerializerMethodField(read_only=True)
user_account = UserSerializer(read_only=True)

class Meta:
model = BusinessAccountMetaData
fields = "__all__"

def get_influencer_ids(self, business_meta_data):
completed_orders = Order.objects.filter(
buyer=business_meta_data.user_account, status="completed"
)
influencer_ids = set()

for completed_order in completed_orders:
completed_order_items = OrderItem.objects.filter(order_id=completed_order)
package_ids = completed_order_items.values_list("package_id", flat=True)
influencers = Package.objects.filter(id__in=package_ids).values_list(
"influencer_id", flat=True
)
influencer_ids.update(influencers)

return list(influencer_ids)

def get_is_twitter_connected(self, business_meta_data):
userAccount = business_meta_data.user_account
if userAccount.twitter_account:
return True
return False


def get_is_wallet_connected(self, business_meta_data):
user_wallet = Wallet.objects.filter(user_id = business_meta_data.user_account)
if(user_wallet):
return True
return False

def get_user_twitter_profile_image(self, business_meta_data):
userAccount = business_meta_data.user_account
try:
return userAccount.twitter_account.profile_image_url
except Exception as e:
return ""

class TwitterReadSerializer(serializers.ModelSerializer):
class Meta:
Expand Down
4 changes: 4 additions & 0 deletions src/api/marketplace/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'core'

def ready(self) -> None:
import core.signals
super().ready()
10 changes: 9 additions & 1 deletion src/api/marketplace/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

import requests
from decouple import config

from packages.models import Service
from .models import Configuration

def get_twitter_usage():
url = "https://api.twitter.com/2/usage/tweets"
headers = {"Authorization": f"Bearer {config('TWITTER_BEARER_TOKEN')}"}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()


def update_priority_fees():
services = Service.objects.all()
current_platform_fees = int(
Configuration.objects.get(key="platform_fees").value)
services.update(platform_fees=current_platform_fees)
14 changes: 14 additions & 0 deletions src/api/marketplace/core/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# From the configuration model, whenever the key "priority_fees" is updated, I want to run a function
# that will update the priority fees in the database.

from django.db.models.signals import post_save
from django.dispatch import receiver

from .models import Configuration
from .services import update_priority_fees


@receiver(post_save, sender=Configuration)
def post_save_update_priority_fees(sender, instance, created, **kwargs):
if instance.key == "platform_fees" and not created:
update_priority_fees()
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,18 @@ export default function InfluencersCards({
justifyContent={"center"}
alignItems={"center"}
>
<Typography variant="subtitle1" fontWeight={"bold"}>
<Typography variant="subtitle2" fontWeight={"bold"}>
Followers:
</Typography>
<Typography
variant="subtitle1"
variant="subtitle2"
fontWeight={"light"}
sx={{ ml: 1 }}
>
{influencer?.followers}
</Typography>
</Box>
<Typography variant="subtitle1" fontWeight={"bold"}>
<Typography variant="subtitle2" fontWeight={"bold"}>
{`${influencer?.minPrice} - ${influencer?.maxPrice}`}
</Typography>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app/business/explore/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default function Explore({}: Props) {
{pagination?.total_data_count ?? 0} Results
</Typography>
{/* The step should be in the database with the corresponding route */}
{/* <HelperButton step={"filters"} /> */}
<HelperButton step={"top_matches"} />
</Box>
<Grid
container
Expand Down
4 changes: 2 additions & 2 deletions src/ui/app/business/messages/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ export default function BusinessMessages() {
);
if (isSuccess) {
// Fetching all user-message and if there's exactly 1 object, show the user guide
if (data?.data?.orders?.length == 1) {
if (data?.pagination?.total_data_count == 1) {
setStepIndex(0);
setRun(true);
}
if (data?.data?.orders?.length > 0) {
if (data?.pagination?.total_data_count > 0) {
setHasAMessage(true);
}
}
Expand Down
40 changes: 13 additions & 27 deletions src/ui/app/business/profile-preview/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Image from "next/image";
import NotFound from "@/public/svg/not_found.svg";
import { stringToColor } from "@/src/utils/helper";
import { BADGES } from "@/src/utils/consts";
import { getProfileCompletedStatus } from "@/src/services/profileCompletion";

type Props = {
params: {
Expand All @@ -48,22 +49,6 @@ const styles = {
},
};

const getProfileCompletedStatus: (businessDetails: any) => string = (
businessDetails
) => {
if (businessDetails) {
let count = 0;
if (businessDetails?.isTwitterAccountConnected) count += 5;
if (businessDetails?.isWalletConnected) count += 5;
count +=
Object.values(businessDetails).filter(
(value) => value !== "" && value !== null
).length - 7;
return `${count} / ${10 + Object.keys(businessDetails).length - 7}`;
}
return "-";
};

const formatTwitterFollowers = (followersCount: any) => {
if (followersCount >= 1000000) {
// Convert to millions format
Expand All @@ -80,8 +65,7 @@ const formatTwitterFollowers = (followersCount: any) => {
export default function BusinessProfilePreview({ params }: Props) {
const [isProfileComplete, setIsProfileComplete] = useState(false);
const [collaborations, setCollaborations] = useState([]);
const [businessDetails, setBusinessDetails] =
useState<BasicBusinessDetailsType>();
const [businessDetails, setBusinessDetails] = useState<any>();
const user = useAppSelector((state) => state.user?.user);

const router = useRouter();
Expand All @@ -104,6 +88,8 @@ export default function BusinessProfilePreview({ params }: Props) {
.replace(/\s/g, "")
.split("/");

console.log(completionStringArr);

return (
(parseInt(completionStringArr[0]) / parseInt(completionStringArr[1])) *
100
Expand Down Expand Up @@ -160,8 +146,6 @@ export default function BusinessProfilePreview({ params }: Props) {
if (isSuccess) {
setBusinessDetails({
...data?.data,
isTwitterAccountConnected: !!user?.twitter_account,
isWalletConnected: !!user?.wallets?.length,
});
getCollaborators(data?.data?.influencer_ids);
}
Expand Down Expand Up @@ -211,23 +195,25 @@ export default function BusinessProfilePreview({ params }: Props) {
alignItems: "center",
}}
>
{user?.twitter_account?.profile_image_url ? (
{!!businessDetails?.user_twitter_profile_image ? (
<Avatar
alt={"Business Account Image"}
src={user?.twitter_account?.profile_image_url}
src={businessDetails?.user_twitter_profile_image}
sx={{
width: 138,
height: 138,
}}
/>
) : (
<Avatar
alt={businessDetails?.business_name}
src={businessDetails?.business_name}
alt={businessDetails?.user_account?.username}
src={businessDetails?.user_account?.username}
sx={{
width: 138,
height: 138,
bgcolor: stringToColor(user?.username ?? ""),
bgcolor: stringToColor(
businessDetails?.user_account?.username ?? ""
),
}}
/>
)}
Expand Down Expand Up @@ -412,7 +398,7 @@ export default function BusinessProfilePreview({ params }: Props) {
margin: "20px",
}}
>
{user?.role?.name === "business_owner" ? (
{user?.id == params?.id ? (
<Button
fullWidth
variant={"contained"}
Expand Down Expand Up @@ -511,7 +497,7 @@ export default function BusinessProfilePreview({ params }: Props) {
<Typography fontWeight={"bold"} sx={{ mt: 2 }}>
{BADGES[getCurrentBadgeIndex()].name}
</Typography>
{user?.role?.name === "business_owner" ? (
{user?.id == params?.id ? (
isProfileComplete ? (
<Typography variant="subtitle1" sx={{ color: "#626262" }}>
Profile complete! Enjoy your upgraded badge & enhanced
Expand Down
21 changes: 3 additions & 18 deletions src/ui/app/influencer/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Joyride, { ACTIONS, EVENTS, STATUS } from "react-joyride";
import XfluencerLogo from "@/public/svg/Xfluencer_Logo_Beta.svg";
import { DriveEta } from "@mui/icons-material";
import WalletConnectModal from "@/src/components/web3Components/walletConnectModal";
import { getProfileCompletedStatus } from "@/src/services/profileCompletion";

const tabs = [
{
Expand All @@ -72,22 +73,6 @@ const tabs = [
},
];

const getProfileCompletedStatus: (businessDetails: any) => string = (
businessDetails
) => {
if (businessDetails) {
let count = 0;
if (businessDetails?.isTwitterAccountConnected) count += 5;
if (businessDetails?.isWalletConnected) count += 5;
count +=
Object.values(businessDetails).filter(
(value) => value !== "" && value !== null
).length - 7;
return `${count} / ${10 + Object.keys(businessDetails).length - 7}`;
}
return "-";
};

export default function BusinessDashboardPage() {
const router = useRouter();
const searchParams = useSearchParams();
Expand Down Expand Up @@ -640,8 +625,7 @@ export default function BusinessDashboardPage() {
)
.replace(/\s/g, "")
.split("/");

return (
return (
(parseInt(completionStringArr[0]) / parseInt(completionStringArr[1])) *
100
);
Expand Down Expand Up @@ -1104,6 +1088,7 @@ export default function BusinessDashboardPage() {
{params?.row?.approved &&
(params?.row?.status === ORDER_ITEM_STATUS.ACCEPTED ||
params?.row?.status === ORDER_ITEM_STATUS.CANCELLED) &&
params?.row?.order_id?.status === ORDER_STATUS.ACCEPTED &&
// Publish date is in the future
dayjs(params?.row?.publish_date) > dayjs() && (
<Tooltip title="Schedule Post" placement="top" arrow>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/app/influencer/messages/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ export default function BusinessMessages() {
);
if (isSuccess) {
// Fetching all user-message and if there's exactly 1 object, show the user guide
if (data?.data?.orders?.length == 1) {
if (data?.pagination?.total_data_count == 1) {
setStepIndex(0);
setRun(true);
}
if (data?.data?.orders?.length > 0) {
if (data?.pagination?.total_data_count > 0) {
setHasAMessage(true);
}
}
Expand Down
Loading
Loading