-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed get followers, working on Leader refactor * did leader refactor * Fixed leader count pairing * frontend addition part 1 * Wrote popular user component stub, working through popularLeaderboard * more fe work * hooked service, started PopularUser.tsx formatting * Temp commit, broken fonts, need to add scrollable * Working leaderboard scroll, popular user, Popular leaderboard. Next fix leaderboard page, rebase, then add AllTimeBests options * Working leaderboard, pending allTimeBests * Update Leader Model * Added trending user crud routes, trending page * Push for merge. All working, needs formatting to match designers in TrendingUser * trending update * attempt * linter fixes * more linter issues * accidently pushed onboarding reducer thing --------- Co-authored-by: CamPlume1 <[email protected]> Co-authored-by: leoRysing <[email protected]>
- Loading branch information
1 parent
286a57e
commit 4b1952e
Showing
24 changed files
with
806 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package controllers | ||
|
||
import ( | ||
"backend/src/services" | ||
"github.com/gin-gonic/gin" | ||
"net/http" | ||
) | ||
|
||
type TrendingController struct { | ||
trendingService *services.TrendingUserService | ||
} | ||
|
||
func NewTrendingController(trendingService *services.TrendingUserService) *TrendingController { | ||
return &TrendingController{ | ||
trendingService: trendingService, | ||
} | ||
} | ||
|
||
// GetTrending godoc | ||
// | ||
// @Summary Gets all trending Users | ||
// @Description Returns all trending users as trending user objects | ||
// @ID get-all-followings | ||
// @Tags followings | ||
// @Produce json | ||
// @Success 200 {object} []models.Followings | ||
// @Failure 404 {string} string "Failed to fetch followers: 404 Error" | ||
// @Router /api/following/ [get] | ||
func (tre *TrendingController) GetTrending(c *gin.Context) { | ||
trending, err := tre.trendingService.GetTrendingUsers() | ||
if err != nil { | ||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch users", "msg": err}) | ||
return | ||
} | ||
|
||
c.JSON(http.StatusOK, trending) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package models | ||
|
||
type Leader struct { | ||
FollowingUserID string `gorm:"type:varchar(255);" json:"following_user_id"` | ||
FollowerCount uint `gorm:"type:int;" json:"follower_count"` | ||
|
||
//Must be Preloaded | ||
FollowingUser User `gorm:"foreignKey:FollowingUserID;references:ID" json:"leader_user"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package models | ||
|
||
type TrendingUser struct { | ||
UserID string `gorm:"type:varchar(255);" json:"user_id"` | ||
// Retrieve from positions | ||
DayGainPct float64 `gorm:"type:numeric(12,2);not null" json:"day_gain_pct"` | ||
|
||
//Must be Preloaded | ||
TrendingUserReference User `gorm:"foreignKey:UserID;references:ID" json:"trending_user_reference"` | ||
} | ||
|
||
func NewTrendingUser(userID string, gainPCT float64) *TrendingUser { | ||
return &TrendingUser{ | ||
UserID: userID, | ||
DayGainPct: gainPCT, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package services | ||
|
||
import ( | ||
"backend/src/models" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type TrendingUserService struct { | ||
DB *gorm.DB | ||
} | ||
|
||
func NewTrendingUserService(db *gorm.DB) *TrendingUserService { | ||
return &TrendingUserService{ | ||
DB: db, | ||
} | ||
} | ||
|
||
func (tre *TrendingUserService) GetTrendingUsers() ([]models.TrendingUser, error) { | ||
|
||
var trending []models.TrendingUser | ||
|
||
if err := tre.DB.Table("user_portfolios"). | ||
Preload("TrendingUserReference"). | ||
Select("user_id, day_gain_pct"). | ||
Order("day_gain_pct DESC"). | ||
Limit(10). | ||
Find(&trending).Error; err != nil { | ||
return nil, err | ||
} | ||
|
||
return trending, nil | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { ScrollView, View } from 'react-native'; | ||
import { Leader } from '../types/types'; | ||
import PopularUser from './PopularUser'; | ||
|
||
|
||
|
||
type PopularProps = { | ||
leaderboard: Leader[]; | ||
} | ||
|
||
const PopularLeaderboard: React.FC<PopularProps> = ({leaderboard}: PopularProps) => { | ||
|
||
return ( | ||
<ScrollView> | ||
{ | ||
leaderboard.map((leader, index) => ( | ||
<React.Fragment key={index}> | ||
<PopularUser leader={leader} /> | ||
{index < leaderboard.length - 1 && <Separator />} | ||
</React.Fragment> | ||
))} | ||
</ScrollView> | ||
) | ||
} | ||
const Separator = () => <View style={{ height: 15 }} />; | ||
|
||
export default PopularLeaderboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { ScrollView, View } from 'react-native'; | ||
import { Trending } from '../types/types'; | ||
import TrendingUser from './TrendingUser'; | ||
|
||
|
||
|
||
type TrendingProps = { | ||
trendingboard: Trending[]; | ||
} | ||
|
||
const PopularTrendingBoard: React.FC<TrendingProps> = ({trendingboard}: TrendingProps) => { | ||
|
||
return ( | ||
<ScrollView> | ||
{ | ||
trendingboard.map((trending, index) => ( | ||
<React.Fragment key={index}> | ||
<TrendingUser trending={trending} /> | ||
{index < trendingboard.length - 1 && <Separator />} | ||
</React.Fragment> | ||
))} | ||
</ScrollView> | ||
) | ||
} | ||
const Separator = () => <View style={{ height: 15 }} />; | ||
|
||
export default PopularTrendingBoard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
import React from 'react'; | ||
import {Image, StyleSheet, Text, View} from 'react-native'; | ||
import { Leader } from '../types/types'; | ||
|
||
type PopularUserProps = { | ||
leader: Leader; | ||
} | ||
|
||
const PopularUser: React.FC<PopularUserProps> = ({ leader }: PopularUserProps) => { | ||
return ( | ||
<View style={styles.container}> | ||
{/* Column for image */} | ||
<View style={[styles.column, styles.imageColumn]}> | ||
<View style={styles.imageContainer}> | ||
<Image | ||
source={{uri: leader.leader_user.image_url}} | ||
style={styles.image} | ||
/> | ||
</View> | ||
</View> | ||
|
||
<View style={[styles.column, styles.textColumn]}> | ||
<View style={styles.textContainer}> | ||
<Text style={styles.nameText}> | ||
{leader.leader_user.first_name} {leader.leader_user.last_name} | ||
</Text> | ||
<Text style={styles.actionText}> | ||
Recent: Recent actions will display{"\n"} here | ||
</Text> | ||
</View> | ||
</View> | ||
|
||
|
||
<View style={[styles.column, styles.followersColumn]}> | ||
<Image | ||
source={require("../assets/followers_logo.png")} | ||
style={styles.followersLogo} | ||
/> | ||
<Text style={styles.followersText}> | ||
{leader.follower_count} | ||
</Text> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
paddingHorizontal: 10, | ||
}, | ||
column: { | ||
flex: 1, | ||
}, | ||
imageColumn: { | ||
flex: 0.17, | ||
}, | ||
textColumn: { | ||
flex: 0.65, | ||
}, | ||
followersColumn: { | ||
flex: 0.18, | ||
flexDirection: 'row', // Check | ||
justifyContent: 'flex-end', //check | ||
}, | ||
imageContainer: { | ||
width: 40, | ||
height: 40, | ||
borderRadius: 20, | ||
overflow: 'hidden', | ||
}, | ||
image: { | ||
width: "100%", | ||
height: "100%", | ||
}, | ||
textContainer: { | ||
flex: 1, | ||
}, | ||
actionText: { | ||
fontSize: 8, | ||
color: '#787878', | ||
}, | ||
nameText: { | ||
fontWeight: 'bold', | ||
fontSize: 12, | ||
marginBottom: 1, | ||
color: '#787878', | ||
}, | ||
followersText: { | ||
alignSelf: 'flex-end', | ||
color: '#787878', | ||
}, | ||
followersLogo: { | ||
width: 20, | ||
height: 20, | ||
marginRight: 5, | ||
} | ||
}); | ||
|
||
export default PopularUser; |
Oops, something went wrong.