Skip to content

Commit

Permalink
fix: attempt to fix workflow (#52)
Browse files Browse the repository at this point in the history
* fix: attempt to fix workflow

* fix: linting issues
  • Loading branch information
elhmn committed Aug 17, 2021
1 parent 1f7f935 commit b06d255
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 21 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/backend-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Backend Lint

on:
push:
branches: [ main ]
paths:
- backend
pull_request:
paths:
- backend
- .github/workflows/backend-lint.yaml

jobs:
build:
Expand Down
12 changes: 2 additions & 10 deletions backend/app/organisation/articles_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package organisation
import (
"errors"
"fmt"
"github.com/osscameroon/yotas/db"
"strings"
"time"

"github.com/osscameroon/yotas/db"
)

//CreateArticle Add an Articles for an Organisations. The return an error if something when wrong
func CreateArticle(article *Articles) error {

if strings.TrimSpace(article.Name) == "" {
return errors.New("article name can't be empty")
}
Expand All @@ -32,7 +32,6 @@ func CreateArticle(article *Articles) error {

//GetArticle Retrieve an Articles an return a *Articles. If the article are not found the will return an nil pointer with an error
func GetArticle(articleID uint) (*Articles, error) {

var article Articles
result := db.Session.Where("id = ?", articleID).First(&article)
if result.Error != nil {
Expand All @@ -44,7 +43,6 @@ func GetArticle(articleID uint) (*Articles, error) {

//UpdateArticle update an Articles
func UpdateArticle(article *Articles) error {

article.UpdatedAt = time.Now().UTC()
result := db.Session.Save(article)
return result.Error
Expand All @@ -58,7 +56,6 @@ func DeleteArticle(articleID uint) error {

//CreateOrganisationArticle Create a new OrganisationsArticles
func CreateOrganisationArticle(organisationID uint, articleID uint) error {

return db.Session.Create(&OrganisationsArticles{
OrganisationId: organisationID,
ArticleId: articleID,
Expand All @@ -68,7 +65,6 @@ func CreateOrganisationArticle(organisationID uint, articleID uint) error {

//GetOrganisationArticles Get a list of Articles related to an Organisations
func GetOrganisationArticles(organisationID uint, categoryId string, limit int, offset int, search string, priceGte int, priceLte int, sort string) ([]Articles, error) {

results := []Articles{}
search = fmt.Sprintf("%s%s%s", "%", search, "%")
err := db.Session.Model(&Articles{}).
Expand All @@ -82,7 +78,6 @@ func GetOrganisationArticles(organisationID uint, categoryId string, limit int,

//CreateArticlePictures Add a list of ArticlesPictures for an Articles.
func CreateArticlePictures(articleID uint, picturesID []uint) error {

if len(picturesID) == 0 {
return nil
}
Expand All @@ -98,7 +93,6 @@ func CreateArticlePictures(articleID uint, picturesID []uint) error {

//GetArticlePictures Get all Pictures of an Articles
func GetArticlePictures(articleID uint) ([]Pictures, error) {

results := []Pictures{}
err := db.Session.Model(&Pictures{}).
Joins("JOIN articles_pictures on articles_pictures.picture_id = pictures.id and articles_pictures.article_id = ?", articleID).
Expand All @@ -116,7 +110,6 @@ func DeleteArticlePictures(articleID uint) error {
//DeleteArticlePicturesWithID Delete all ArticlesPictures of an Articles
// if invertDeletion is true we delete all ArticlesPictures where ID is not in picturesID
func DeleteArticlePicturesWithID(articleID uint, picturesID []uint, invertDeletion ...bool) error {

if len(picturesID) == 0 {
return nil
}
Expand All @@ -125,5 +118,4 @@ func DeleteArticlePicturesWithID(articleID uint, picturesID []uint, invertDeleti
}

return db.Session.Where("article_id = ? AND pictures_id NOT IN ?", articleID, picturesID).Delete(&ArticlesPictures{}).Error

}
5 changes: 0 additions & 5 deletions backend/app/organisation/articles_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type ArticlesPresenter struct {

//CreateArticleHandler is a handler for CreateArticle
func CreateArticleHandler(ctx *gin.Context) {

if strings.TrimSpace(ctx.GetHeader("Tenant")) == "" {
ctx.String(http.StatusBadRequest, ErrTenantNotProvided.Error())
return
Expand Down Expand Up @@ -85,7 +84,6 @@ func CreateArticleHandler(ctx *gin.Context) {

//GetArticleHandler is a handler for GetArticle
func GetArticleHandler(ctx *gin.Context) {

if strings.TrimSpace(ctx.GetHeader("Tenant")) == "" {
ctx.String(http.StatusBadRequest, ErrTenantNotProvided.Error())
return
Expand Down Expand Up @@ -117,7 +115,6 @@ func GetArticleHandler(ctx *gin.Context) {

//GetOrganisationArticlesHandler is a handler for GetOrganisationArticles
func GetOrganisationArticlesHandler(ctx *gin.Context) {

organisationID, err := strconv.Atoi(ctx.GetHeader("Tenant"))
if err != nil {
ctx.String(http.StatusBadRequest, ErrTenantNotProvided.Error())
Expand Down Expand Up @@ -180,7 +177,6 @@ func GetOrganisationArticlesHandler(ctx *gin.Context) {

//UpdateArticleHandler is a handler for UpdateArticle
func UpdateArticleHandler(ctx *gin.Context) {

if strings.TrimSpace(ctx.GetHeader("Tenant")) == "" {
ctx.String(http.StatusBadRequest, ErrTenantNotProvided.Error())
return
Expand Down Expand Up @@ -269,7 +265,6 @@ func UpdateArticleHandler(ctx *gin.Context) {

//DeleteArticleHandler is a handler for DeleteArticle
func DeleteArticleHandler(ctx *gin.Context) {

articleID, err := strconv.Atoi(ctx.Param("articleID"))
if err != nil {
ctx.JSON(http.StatusBadRequest, "Article id must be an int")
Expand Down
1 change: 0 additions & 1 deletion backend/app/organisation/pictures_bd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "github.com/osscameroon/yotas/db"

//GetOrganisationPicture Get a Pictures linked to an Organisations
func GetOrganisationPicture(pictureID, organisationID uint) (*Pictures, error) {

var picture Pictures
result := db.Session.Where("id = ? AND organisation_id = ?", pictureID, organisationID).First(&picture)
if result.Error != nil {
Expand Down
1 change: 0 additions & 1 deletion backend/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var Session *gorm.DB

//Init start the connection to the database
func Init() {

var err error

params := fmt.Sprintf(
Expand Down

0 comments on commit b06d255

Please sign in to comment.