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

image display and filter #1078

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 18 additions & 6 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (db database) GetBountiesCount(r *http.Request) int64 {
paidQuery := ""

if open != "" && open == "true" {
openQuery = "AND assignee = ''"
openQuery = "AND assignee = '' AND paid != true"
assignedQuery = ""
}
if assingned != "" && assingned == "true" {
Expand All @@ -458,7 +458,11 @@ func (db database) GetBountiesCount(r *http.Request) int64 {
}
}
if paid != "" && paid == "true" {
paidQuery = "AND paid = true"
if open != "" && open == "true" && assingned != "" && assingned == "true" {
paidQuery = "OR paid = true"
} else {
paidQuery = "AND paid = true"
}
}

var count int64
Expand Down Expand Up @@ -497,7 +501,7 @@ func (db database) GetOrganizationBounties(r *http.Request, org_uuid string) []B
searchQuery = fmt.Sprintf("WHERE LOWER(title) LIKE %s", "'%"+search+"%'")
}
if open != "" && open == "true" {
openQuery = "AND assignee = ''"
openQuery = "AND assignee = '' AND paid != true"
assignedQuery = ""
}
if assingned != "" && assingned == "true" {
Expand All @@ -508,7 +512,11 @@ func (db database) GetOrganizationBounties(r *http.Request, org_uuid string) []B
}
}
if paid != "" && paid == "true" {
paidQuery = "AND paid = true"
if open != "" && open == "true" && assingned != "" && assingned == "true" {
paidQuery = "OR paid = true"
} else {
paidQuery = "AND paid = true"
}
}

query := `SELECT * FROM bounty WHERE org_uuid = '` + org_uuid + `'`
Expand Down Expand Up @@ -592,7 +600,7 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
searchQuery = fmt.Sprintf("AND LOWER(title) LIKE %s", "'%"+search+"%'")
}
if open != "" && open == "true" {
openQuery = "AND assignee = ''"
openQuery = "AND assignee = '' AND paid != true"
assignedQuery = ""
}
if assingned != "" && assingned == "true" {
Expand All @@ -603,7 +611,11 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
}
}
if paid != "" && paid == "true" {
paidQuery = "AND paid = true"
if open != "" && open == "true" && assingned != "" && assingned == "true" {
paidQuery = "OR paid = true"
} else {
paidQuery = "AND paid = true"
}
}

query := "SELECT * FROM public.bounty WHERE show != false"
Expand Down
13 changes: 1 addition & 12 deletions frontend/app/src/bounties/BountyDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import styled from 'styled-components';
import { isString } from 'lodash';
import { OrganizationText, OrganizationWrap } from 'people/utils/style';
import { Link } from 'react-router-dom';
import { useStores } from 'store';
import { Organization } from 'store/main';
import { colors } from '../config/colors';
import { LanguageObject } from '../people/utils/languageLabelStyle';
import NameTag from '../people/utils/NameTag';
Expand Down Expand Up @@ -121,17 +119,8 @@ const BountyDescription = (props: BountiesDescriptionProps) => {
const [dataValue, setDataValue] = useState([]);
const [replitLink, setReplitLink] = useState('');
const [descriptionImage, setDescriptionImage] = useState('');
const [org, setOrg] = useState<Organization | undefined>(undefined);
const { main } = useStores();

const fetchOrg = async () => {
if (!props.org_uuid) return;
const org = await main.getUserOrganizationByUuid(props.org_uuid);
setOrg(org);
};

useEffect(() => {
fetchOrg();
if (props.description) {
const found = props?.description.match(/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))(?![^`]*`)/);
setReplitLink(
Expand Down Expand Up @@ -179,7 +168,7 @@ const BountyDescription = (props: BountiesDescriptionProps) => {
<OrganizationWrap>
<Img
title={`${props.name} logo`}
src={org?.img || '/static/person_placeholder.png'}
src={props.org_img || '/static/person_placeholder.png'}
/>
<OrganizationText>{props.name}</OrganizationText>
<img
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/bounties/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface BountiesDescriptionProps {
name?: string;
uuid?: string;
org_uuid?: string;
org_img?: string;
}

export interface BountiesPriceProps {
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/people/utils/AssignedUnassignedBounties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const Bounties = (props: BountiesProps) => {
{...props}
title={title}
img={person.img}
org_img={props.img}
codingLanguage={codingLanguage}
created={created}
/>
Expand Down Expand Up @@ -184,6 +185,7 @@ const Bounties = (props: BountiesProps) => {
{...person}
{...props}
img={person.img}
org_img={props.img}
title={title}
codingLanguage={codingLanguage}
widget={widget}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/people/utils/PaidBounty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const PaidBounty = (props: PaidBountiesProps) => {
title={props.title}
codingLanguage={props.codingLanguage}
isPaid={true}
org_img={props.img}
/>
<PriceUserContainer Price_User_Container_Border={color.primaryColor.P400}>
<BountyPrice
Expand Down
5 changes: 5 additions & 0 deletions frontend/app/src/people/widgetViews/WantedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function WantedView(props: WantedViews2Props) {
show = true,
paid = false
} = props;

const titleString = one_sentence_summary || title || '';
const isMobile = useIsMobile();
const { ui, main } = useStores();
Expand Down Expand Up @@ -157,6 +158,7 @@ function WantedView(props: WantedViews2Props) {
description={description}
name={name}
org_uuid={org_uuid}
img={img}
/>
</BountyBox>
) : (
Expand Down Expand Up @@ -199,6 +201,9 @@ function WantedView(props: WantedViews2Props) {
paid={paid}
isMine={isMine}
titleString={titleString}
name={name}
org_uuid={org_uuid}
img={img}
/>
);
};
Expand Down
Loading