Skip to content

Commit

Permalink
Fix/coding languages (#601)
Browse files Browse the repository at this point in the history
* changed coding_language to coding_languages

* changed coding_language column to coding_languages
  • Loading branch information
elraphty authored Jul 20, 2023
1 parent e483282 commit 83799ca
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 52 deletions.
48 changes: 24 additions & 24 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,30 +327,30 @@ type YoutubeDownload struct {
}

type Bounty struct {
ID uint `json:"id"`
OwnerID string `json:"owner_id"`
Paid bool `json:"paid"`
Show bool `json:"show"`
Type string `json:"type"`
Award string `json:"award"`
AssignedHours uint8 `json:"assigned_hours"`
BountyExpires string `json:"bounty_expires"`
CommitmentFee uint64 `json:"commitment_fee"`
Price string `json:"price"`
Title string `json:"title"`
Tribe string `json:"tribe"`
Created int64 `json:"created"`
Assignee string `json:"assignee"`
TicketUrl string `json:"ticket_url"`
Description string `json:"description"`
WantedType string `json:"wanted_type"`
Deliverables string `json:"deliverables"`
GithubDescription bool `json:"github_description"`
OneSentenceSummary string `json:"one_sentence_summary"`
EstimatedSessionLength string `json:"estimated_session_length"`
EstimatedCompletionDate string `json:"estimated_completion_date"`
Updated *time.Time `json:"updated"`
CodingLanguage JSONB `json:"coding_language", type:bytea not null default '[]'::bytea`
ID uint `json:"id"`
OwnerID string `json:"owner_id"`
Paid bool `json:"paid"`
Show bool `json:"show"`
Type string `json:"type"`
Award string `json:"award"`
AssignedHours uint8 `json:"assigned_hours"`
BountyExpires string `json:"bounty_expires"`
CommitmentFee uint64 `json:"commitment_fee"`
Price string `json:"price"`
Title string `json:"title"`
Tribe string `json:"tribe"`
Created int64 `json:"created"`
Assignee string `json:"assignee"`
TicketUrl string `json:"ticket_url"`
Description string `json:"description"`
WantedType string `json:"wanted_type"`
Deliverables string `json:"deliverables"`
GithubDescription bool `json:"github_description"`
OneSentenceSummary string `json:"one_sentence_summary"`
EstimatedSessionLength string `json:"estimated_session_length"`
EstimatedCompletionDate string `json:"estimated_completion_date"`
Updated *time.Time `json:"updated"`
CodingLanguages pq.StringArray `gorm:"type:text[];not null default:'[]'" json:"coding_languages"`
}

type BountyData struct {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/form/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ export const wantedCodingTaskSchema: FormField[] = [
options: []
},
{
name: 'coding_language',
name: 'coding_languages',
label: 'Coding Language',
type: 'creatablemultiselect',
options: codingLanguages
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/people/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export interface WantedSummaryProps {
paid: boolean;
badgeRecipient: string;
loomEmbedUrl: string;
coding_language: { [key: string]: any };
coding_languages: { [key: string]: any };
estimated_session_length: string;
assignee: Person;
fromBountyPage: string;
Expand Down Expand Up @@ -346,7 +346,7 @@ export interface WantedViews2Props extends WantedViewsProps {
issue?: string;
repo?: string;
type?: string;
coding_language?: any;
coding_languages?: any;
fromBountyPage?: boolean;
}

Expand Down
17 changes: 12 additions & 5 deletions frontend/app/src/people/main/FocusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const B = styled.div<BProps>`
overflow-y: auto;
box-sizing: border-box;
${EnvWithScrollBar({
thumbColor: '#5a606c',
trackBackgroundColor: 'rgba(0,0,0,0)'
})}
thumbColor: '#5a606c',
trackBackgroundColor: 'rgba(0,0,0,0)'
})}
`;
function FocusedView(props: FocusViewProps) {
const {
Expand Down Expand Up @@ -335,6 +335,13 @@ function FocusedView(props: FocusViewProps) {
[s.name]: wanted['one_sentence_summary'] || wanted['title']
};
}
else if (s.name === 'coding_languages') {
let coding_languages = wanted['coding_languages'].length
? wanted['coding_languages'].map((lang: any) => ({ value: lang, label: lang })) : [];
return {
[s.name]: coding_languages
};
}
return {
[s.name]: wanted[s.name]
};
Expand Down Expand Up @@ -396,8 +403,8 @@ function FocusedView(props: FocusViewProps) {
extraHTML={
ui.meInfo.verification_signature
? {
twitter: `<span>Post this to your twitter account to verify:</span><br/><strong>Sphinx Verification: ${ui.meInfo.verification_signature}</strong>`
}
twitter: `<span>Post this to your twitter account to verify:</span><br/><strong>Sphinx Verification: ${ui.meInfo.verification_signature}</strong>`
}
: {}
}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/people/utils/BountyCreationConstant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const BountyDetailsCreationData = {
heading: 'Basic info',
sub_heading: ' ',
schema: ['one_sentence_summary', 'ticket_url'],
schema2: ['wanted_type', 'coding_language'],
schema2: ['wanted_type', 'coding_languages'],
required: ['one_sentence_summary', 'wanted_type'],
outerContainerStyle: {
minWidth: '712px',
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/src/people/widgetViews/WantedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function WantedView(props: WantedViews2Props) {
ticketUrl,
repo,
type,
coding_language,
coding_languages,
assignee,
estimated_session_length,
loomEmbedUrl,
Expand Down Expand Up @@ -97,11 +97,11 @@ function WantedView(props: WantedViews2Props) {
}

useEffect(() => {
if (coding_language) {
const values = coding_language.map((value: any) => ({ ...value }));
if (coding_languages) {
const values = coding_languages.map((value: any) => ({ label: value, value: value }));
setLabels(values);
}
}, [coding_language]);
}, [coding_languages]);

const renderTickets = () => {
const { status } = ticketUrl
Expand Down
18 changes: 9 additions & 9 deletions frontend/app/src/people/widgetViews/summaries/WantedSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function WantedSummary(props: WantedSummaryProps) {
paid,
badgeRecipient,
loomEmbedUrl,
coding_language,
coding_languages,
estimated_session_length,
assignee,
fromBountyPage,
Expand Down Expand Up @@ -150,7 +150,7 @@ function WantedSummary(props: WantedSummaryProps) {
value: value?.owner_pubkey || '',
label: `${value.owner_alias} (${value.owner_alias.toLowerCase().replace(' ', '')})` || ''
},
coding_language: coding_language?.map((x: any) => ({ ...x })),
coding_language: coding_languages?.map((x: any) => ({ label: x, value: x })),
estimated_session_length: estimated_session_length,
show: show,
type: type,
Expand All @@ -159,7 +159,7 @@ function WantedSummary(props: WantedSummaryProps) {
formSubmit && formSubmit(newValue);
},
[
coding_language,
coding_languages,
created,
description,
estimated_session_length,
Expand Down Expand Up @@ -194,14 +194,14 @@ function WantedSummary(props: WantedSummaryProps) {

useEffect(() => {
let res;
if (coding_language?.length > 0) {
if (coding_languages?.length > 0) {
res = LanguageObject?.filter(
(value: any) => coding_language?.find((val: any) => val.label === value.label)
(value: any) => coding_languages?.find((val: any) => val === value.label)
);
}
setDataValue(res);
setLabels(res);
}, [coding_language]);
}, [coding_languages]);

const searchParams = useQuery();

Expand All @@ -213,11 +213,11 @@ function WantedSummary(props: WantedSummaryProps) {
}, [owner_idURL, createdURL, searchParams]);

useEffect(() => {
if (coding_language) {
const values = coding_language.map((value: any) => ({ ...value }));
if (coding_languages) {
const values = coding_languages.map((value: any) => ({ label: value, value: value }));
setLabels(values);
}
}, [coding_language]);
}, [coding_languages]);

async function setExtrasPropertyAndSave(propertyName: string, value: any) {
if (peopleWanteds) {
Expand Down
11 changes: 9 additions & 2 deletions frontend/app/src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,15 @@ export class MainStore {
return;
}

if (!body.coding_language || !body.coding_language.length) {
body.coding_language = [];
if (!body.coding_languages || !body.coding_languages.length) {
body.coding_languages = [];
} else {
let languages: string[] = [];
body.coding_languages.forEach((lang: any) => {
languages.push(lang.value);
})

body.coding_languages = languages;
}

try {
Expand Down
7 changes: 4 additions & 3 deletions handlers/bounties.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"

"github.com/go-chi/chi"
"github.com/lib/pq"
"github.com/stakwork/sphinx-tribes/db"
)

Expand Down Expand Up @@ -218,11 +219,11 @@ func MigrateBounties(w http.ResponseWriter, r *http.Request) {
migrateBountyFinal.Deliverables = Deliverables
}

CodingLanguage, ok13 := migrateBounty["coding_language"].(db.PropertyMap)
CodingLanguages, ok13 := migrateBounty["coding_language"].(db.PropertyMap)
if !ok13 {
migrateBountyFinal.CodingLanguage = db.JSONB{}
migrateBountyFinal.CodingLanguages = pq.StringArray{}
} else {
migrateBountyFinal.CodingLanguage = CodingLanguage["value"].(db.JSONB)
migrateBountyFinal.CodingLanguages = CodingLanguages["value"].(pq.StringArray)
}

GithuDescription, ok14 := migrateBounty["github_description"].(bool)
Expand Down
2 changes: 1 addition & 1 deletion handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func generateBountyResponse(bounties []db.BountyData) []db.BountyResponse {
EstimatedSessionLength: bounty.EstimatedSessionLength,
EstimatedCompletionDate: bounty.EstimatedCompletionDate,
Updated: bounty.BountyUpdated,
CodingLanguage: bounty.CodingLanguage,
CodingLanguages: bounty.CodingLanguages,
},
Assignee: db.Person{
ID: bounty.AssigneeId,
Expand Down

0 comments on commit 83799ca

Please sign in to comment.