Merge Github Workflow.

Support Loading Archived Tasks
This commit is contained in:
Mo Tarbin 2024-12-15 18:13:51 -05:00
commit 89b7664176
4 changed files with 89 additions and 43 deletions

View file

@ -1,52 +1,52 @@
name: Build and Push Docker Image # name: Build and Push Docker Image
on: # on:
push: # push:
branches: # branches:
- main # - main
jobs: # jobs:
build: # build:
name: Build and Push Docker Image # name: Build and Push Docker Image
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
# Checkout the code from the repository # # Checkout the code from the repository
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v3 # uses: actions/checkout@v3
# # Download the latest release binary from GitHub releases # # # Download the latest release binary from GitHub releases
# - name: Download latest release binary # # - name: Download latest release binary
# run: | # # run: |
# latest_release=$(curl --silent "https://api.github.com/repos/donetick/donetick/releases/latest" | jq -r '.tag_name') # # latest_release=$(curl --silent "https://api.github.com/repos/donetick/donetick/releases/latest" | jq -r '.tag_name')
# curl -L "https://github.com/donetick/donetick/releases/download/${latest_release}/donetick_Linux_x86_64.tar.gz" -o donetick_Linux_x86_64.tar.gz # # curl -L "https://github.com/donetick/donetick/releases/download/${latest_release}/donetick_Linux_x86_64.tar.gz" -o donetick_Linux_x86_64.tar.gz
# tar -xzf donetick_Linux_x86_64.tar.gz # # tar -xzf donetick_Linux_x86_64.tar.gz
# chmod +x ./donetick # # chmod +x ./donetick
# Log in to Docker Hub # # Log in to Docker Hub
- name: Log in to Docker Hub # - name: Log in to Docker Hub
uses: docker/login-action@v2 # uses: docker/login-action@v2
with: # with:
username: ${{ secrets.DOCKER_USERNAME }} # username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} # password: ${{ secrets.DOCKER_PASSWORD }}
# # Log in to GitHub Container Registry # # # Log in to GitHub Container Registry
# - name: Login to GitHub Container Registry # # - name: Login to GitHub Container Registry
# uses: docker/login-action@v3.3.0 # # uses: docker/login-action@v3.3.0
# with: # # with:
# registry: ghcr.io # # registry: ghcr.io
# username: ${{ github.repository_owner }} # # username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }} # # password: ${{ secrets.GITHUB_TOKEN }}
# Build and tag Docker image # # Build and tag Docker image
- name: Build Docker image # - name: Build Docker image
run: | # run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/donetick:latest . # docker build -t ${{ secrets.DOCKER_USERNAME }}/donetick:latest .
# Push Docker image # # Push Docker image
- name: Push Docker image # - name: Push Docker image
run: | # run: |
docker push ${{ secrets.DOCKER_USERNAME }}/donetick:latest # docker push ${{ secrets.DOCKER_USERNAME }}/donetick:latest

View file

@ -10,6 +10,7 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build and Push Docker Image
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -57,4 +58,20 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build and tag Docker image
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/donetick:latest .
# Push Docker image
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/donetick:latest

View file

@ -98,6 +98,26 @@ func (h *Handler) getChores(c *gin.Context) {
}) })
} }
func (h *Handler) getArchivedChores(c *gin.Context) {
u, ok := auth.CurrentUser(c)
if !ok {
c.JSON(500, gin.H{
"error": "Error getting current circle",
})
return
}
chores, err := h.choreRepo.GetArchivedChores(c, u.CircleID, u.ID)
if err != nil {
c.JSON(500, gin.H{
"error": "Error getting chores",
})
return
}
c.JSON(200, gin.H{
"res": chores,
})
}
func (h *Handler) getChore(c *gin.Context) { func (h *Handler) getChore(c *gin.Context) {
currentUser, ok := auth.CurrentUser(c) currentUser, ok := auth.CurrentUser(c)
@ -1276,6 +1296,7 @@ func Routes(router *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware) {
choresRoutes.Use(auth.MiddlewareFunc()) choresRoutes.Use(auth.MiddlewareFunc())
{ {
choresRoutes.GET("/", h.getChores) choresRoutes.GET("/", h.getChores)
choresRoutes.GET("/archived", h.getArchivedChores)
choresRoutes.PUT("/", h.editChore) choresRoutes.PUT("/", h.editChore)
choresRoutes.PUT("/:id/priority", h.updatePriority) choresRoutes.PUT("/:id/priority", h.updatePriority)
choresRoutes.POST("/", h.createChore) choresRoutes.POST("/", h.createChore)

View file

@ -52,7 +52,15 @@ func (r *ChoreRepository) GetChore(c context.Context, choreID int) (*chModel.Cho
func (r *ChoreRepository) GetChores(c context.Context, circleID int, userID int) ([]*chModel.Chore, error) { func (r *ChoreRepository) GetChores(c context.Context, circleID int, userID int) ([]*chModel.Chore, error) {
var chores []*chModel.Chore var chores []*chModel.Chore
// if err := r.db.WithContext(c).Preload("Assignees").Where("is_active = ?", true).Order("next_due_date asc").Find(&chores, "circle_id = ?", circleID).Error; err != nil { // if err := r.db.WithContext(c).Preload("Assignees").Where("is_active = ?", true).Order("next_due_date asc").Find(&chores, "circle_id = ?", circleID).Error; err != nil {
if err := r.db.WithContext(c).Preload("Assignees").Preload("LabelsV2").Joins("left join chore_assignees on chores.id = chore_assignees.chore_id").Where("chores.circle_id = ? AND (chores.created_by = ? OR chore_assignees.user_id = ?)", circleID, userID, userID).Group("chores.id").Order("next_due_date asc").Find(&chores, "circle_id = ?", circleID).Error; err != nil { if err := r.db.WithContext(c).Preload("Assignees").Preload("LabelsV2").Joins("left join chore_assignees on chores.id = chore_assignees.chore_id").Where("chores.circle_id = ? AND (chores.created_by = ? OR chore_assignees.user_id = ?)", circleID, userID, userID).Group("chores.id").Order("next_due_date asc").Find(&chores, "circle_id = ? AND is_active = ?", circleID, true).Error; err != nil {
return nil, err
}
return chores, nil
}
func (r *ChoreRepository) GetArchivedChores(c context.Context, circleID int, userID int) ([]*chModel.Chore, error) {
var chores []*chModel.Chore
if err := r.db.WithContext(c).Preload("Assignees").Preload("LabelsV2").Joins("left join chore_assignees on chores.id = chore_assignees.chore_id").Where("chores.circle_id = ? AND (chores.created_by = ? OR chore_assignees.user_id = ?)", circleID, userID, userID).Group("chores.id").Order("next_due_date asc").Find(&chores, "circle_id = ? AND is_active = ?", circleID, false).Error; err != nil {
return nil, err return nil, err
} }
return chores, nil return chores, nil