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

Fix Race Conditions #153

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
53 changes: 27 additions & 26 deletions db/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,32 +197,33 @@ type SchoolFollow struct {

// ! Very important that SOME FIELDS ARE NOT EVER SERIALIZED TO PROTECT SENSATIVE DATA (json:"-")
type Post struct {
ID EncryptedID `gorm:"primary_key;column:id" json:"id"`
CreatedAt TimeMicros `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt TimeMicros `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
UserID string `gorm:"column:user_id" json:"-"`
SchoolID EncryptedID `gorm:"column:school_id" json:"-"`
School School `gorm:"foreignKey:SchoolID" json:"school"`
FacultyID *EncryptedID `gorm:"column:faculty_id" json:"-"`
Faculty Faculty `gorm:"foreignKey:FacultyID" json:"faculty"`
YearOfStudyID *EncryptedID `gorm:"column:year_of_study_id" json:"-"`
YearOfStudy YearOfStudy `gorm:"foreignKey:YearOfStudyID" json:"year_of_study"`
Title string `gorm:"column:title" json:"title"`
Content string `gorm:"column:content" json:"content"`
Downvote uint `gorm:"column:downvote" json:"downvote"`
Upvote uint `gorm:"column:upvote" json:"upvote"`
VoteScore int `gorm:"column:vote_score" json:"-"` // redundant to return to the user
TrendingScore float64 `gorm:"column:trending_score" json:"trending_score"`
HottestOn *datatypes.Date `gorm:"column:hottest_on" json:"hottest_on"` // intentionally a pointer, so that it defaults to NULL when created and not specified (i.e. not its zero-value)
Hidden bool `gorm:"column:hidden" json:"hidden"`
Sentiment *float64 `gorm:"column:sentiment" json:"sentiment"`
ReportCount uint `gorm:"column:report_count" json:"-"`
ReviewedByMod bool `gorm:"column:reviewed_by_mod" json:"-"`
Edited bool `gorm:"column:edited" json:"edited"`
CategoryID EncryptedID `gorm:"column:category_id" json:"-"`
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
CommentCount uint `gorm:"column:comment_count" json:"comment_count"`
ImgUrls PgTxtArr `gorm:"column:img_urls" json:"img_urls"`
ID EncryptedID `gorm:"primary_key;column:id" json:"id"`
CreatedAt TimeMicros `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt TimeMicros `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
UserID string `gorm:"column:user_id" json:"-"`
SchoolID EncryptedID `gorm:"column:school_id" json:"-"`
School School `gorm:"foreignKey:SchoolID" json:"school"`
FacultyID *EncryptedID `gorm:"column:faculty_id" json:"-"`
Faculty Faculty `gorm:"foreignKey:FacultyID" json:"faculty"`
YearOfStudyID *EncryptedID `gorm:"column:year_of_study_id" json:"-"`
YearOfStudy YearOfStudy `gorm:"foreignKey:YearOfStudyID" json:"year_of_study"`
Title string `gorm:"column:title" json:"title"`
Content string `gorm:"column:content" json:"content"`
Downvote uint `gorm:"column:downvote" json:"downvote"`
Upvote uint `gorm:"column:upvote" json:"upvote"`
VoteScore int `gorm:"column:vote_score" json:"-"` // redundant to return to the user
TrendingScore float64 `gorm:"column:trending_score" json:"trending_score"`
HottestOn *datatypes.Date `gorm:"column:hottest_on" json:"hottest_on"` // intentionally a pointer, so that it defaults to NULL when created and not specified (i.e. not its zero-value)
Hidden bool `gorm:"column:hidden" json:"hidden"`
Sentiment *float64 `gorm:"column:sentiment" json:"sentiment"`
ReportCount uint `gorm:"column:report_count" json:"-"`
ReviewedByMod bool `gorm:"column:reviewed_by_mod" json:"-"`
Edited bool `gorm:"column:edited" json:"edited"`
CategoryID EncryptedID `gorm:"column:category_id" json:"-"`
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
CommentCount uint `gorm:"column:comment_count" json:"comment_count"`
CommentNumerics uint `gorm:"column:comment_numerics" json:"comment_numerics"`
ImgUrls PgTxtArr `gorm:"column:img_urls" json:"img_urls"`
}

// ! Very important that SOME FIELDS ARE NOT EVER SERIALIZED TO PROTECT SENSATIVE DATA (json:"-")
Expand Down
Loading