diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..0a29019 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..71ede88 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ + +## Meilisync +if you use podman make sure to change the host into host.containers.internal +something like this + +debug: true +plugins: + - meilisync.plugin.Plugin +progress: + type: file +source: + type: postgres + host: host.containers.internal + port: 5432 + user: postgres + password: "rawdoggingwings" + database: hiling_dev +meilisearch: + api_url: "http://host.containers.internal:7700" + api_key: 12rchaaonetdadaaoenh + insert_size: 1000 + insert_interval: 10 +sync: + - table: locations + index: locations + plugins: + - meilisync.plugin.Plugin + full: false + fields: + id: + name: + + +and for mac apple silicon chip, pull the image first with command `arch=amd64` then podman compose it + +## Requirements +Meilisearch v 1.35.1 +Meilisync +Postgresql +Redis diff --git a/api/.DS_Store b/api/.DS_Store new file mode 100644 index 0000000..1ce14b0 Binary files /dev/null and b/api/.DS_Store differ diff --git a/api/BaseResponse.go b/api/BaseResponse.go index ae46a0c..9439212 100755 --- a/api/BaseResponse.go +++ b/api/BaseResponse.go @@ -27,6 +27,8 @@ func validationErrorMsg(field string, param string, tag string, typeName string) return fmt.Sprintf("%s character max %s character", field, param) case "required": return fmt.Sprintf("%s is %s", field, tag) + case "alphanum": + return fmt.Sprintf("%s should be number and alphabet only", field) default: return fmt.Sprintf("%s %s", field, tag) } diff --git a/api/image.go b/api/image.go index fda361b..731d8b2 100755 --- a/api/image.go +++ b/api/image.go @@ -3,7 +3,7 @@ package api import ( "net/http" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "github.com/gin-gonic/gin" ) diff --git a/api/location.go b/api/location.go index ef30ec6..2651ba6 100755 --- a/api/location.go +++ b/api/location.go @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v5" diff --git a/api/location_page_visits.go b/api/location_page_visits.go new file mode 100644 index 0000000..778f64e --- /dev/null +++ b/api/location_page_visits.go @@ -0,0 +1 @@ +package api diff --git a/api/news_event.go b/api/news_event.go index f25fbf0..5825325 100755 --- a/api/news_event.go +++ b/api/news_event.go @@ -3,7 +3,7 @@ package api import ( "net/http" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v5/pgtype" ) diff --git a/api/reviews.go b/api/reviews.go index 2f41146..aaaccc9 100755 --- a/api/reviews.go +++ b/api/reviews.go @@ -4,7 +4,7 @@ import ( "log" "net/http" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util/token" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v5" diff --git a/api/server.go b/api/server.go index ca06ef2..186202d 100755 --- a/api/server.go +++ b/api/server.go @@ -3,7 +3,7 @@ package api import ( "fmt" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "git.nochill.in/nochill/hiling_go/util/token" "github.com/gin-contrib/cors" @@ -45,7 +45,7 @@ func (server *Server) getRoutes() { router := gin.Default() router.Use(cors.New(cors.Config{ - AllowOrigins: []string{"http://localhost:5173"}, + AllowOrigins: []string{"http://localhost:5173", "http://192.168.18.164:5173", "http://192.168.1.13:5173"}, AllowCredentials: true, AllowHeaders: []string{"Content-Type", "Content-Length", "Accept-Encoding", "Authorization", "accept", "origin", "Cache-Control", "X-Requested-With", "X-XSRF-TOKEN"}, AllowMethods: []string{"POST", "PUT", "GET", "DELETE", "PATCH"}, diff --git a/api/test/location_test.go b/api/test/location_test.go index b0b3796..5329b76 100755 --- a/api/test/location_test.go +++ b/api/test/location_test.go @@ -10,7 +10,7 @@ import ( "time" mockdb "git.nochill.in/nochill/hiling_go/db/mock" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/jackc/pgx/v5/pgtype" "github.com/stretchr/testify/require" diff --git a/api/test/main_test.go b/api/test/main_test.go index 8678331..9b64d4f 100755 --- a/api/test/main_test.go +++ b/api/test/main_test.go @@ -6,7 +6,7 @@ import ( "time" api "git.nochill.in/nochill/hiling_go/api" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/gin-gonic/gin" "github.com/stretchr/testify/require" diff --git a/api/test/user_test.go b/api/test/user_test.go index e27d519..a618da5 100755 --- a/api/test/user_test.go +++ b/api/test/user_test.go @@ -8,7 +8,7 @@ import ( "testing" mockdb "git.nochill.in/nochill/hiling_go/db/mock" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/gin-gonic/gin" "github.com/stretchr/testify/require" diff --git a/api/user.go b/api/user.go index dfde29e..2718df0 100755 --- a/api/user.go +++ b/api/user.go @@ -8,7 +8,7 @@ import ( "path/filepath" "time" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "git.nochill.in/nochill/hiling_go/util/token" "github.com/gin-gonic/gin" @@ -39,10 +39,8 @@ type createUserResponse struct { func (server *Server) createUser(ctx *gin.Context) { var req createUserRequest if err := ctx.ShouldBindJSON(&req); err != nil { - if err != nil { - ctx.JSON(http.StatusBadRequest, ValidationErrorResponse(err)) - return - } + ctx.JSON(http.StatusBadRequest, ValidationErrorResponse(err)) + return } hashedPassword, err := util.HashPassword(req.Password) diff --git a/data.ms/VERSION b/data.ms/VERSION old mode 100755 new mode 100644 index ce6a70b..6fa8683 --- a/data.ms/VERSION +++ b/data.ms/VERSION @@ -1 +1 @@ -1.6.0 \ No newline at end of file +1.35.1 \ No newline at end of file diff --git a/data.ms/auth/data.mdb b/data.ms/auth/data.mdb old mode 100755 new mode 100644 index 632246a..073df73 Binary files a/data.ms/auth/data.mdb and b/data.ms/auth/data.mdb differ diff --git a/data.ms/auth/lock.mdb b/data.ms/auth/lock.mdb old mode 100755 new mode 100644 index d2a6034..392b4df Binary files a/data.ms/auth/lock.mdb and b/data.ms/auth/lock.mdb differ diff --git a/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/data.mdb b/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/data.mdb deleted file mode 100755 index 75eec7f..0000000 Binary files a/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/data.mdb and /dev/null differ diff --git a/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/lock.mdb b/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/lock.mdb deleted file mode 100755 index d263ef7..0000000 Binary files a/data.ms/indexes/7cfc824a-b5b6-44e5-98e9-36b251867cac/lock.mdb and /dev/null differ diff --git a/data.ms/instance-uid b/data.ms/instance-uid old mode 100755 new mode 100644 index f222759..20b78fa --- a/data.ms/instance-uid +++ b/data.ms/instance-uid @@ -1 +1 @@ -3db8a6fc-efe2-4e2e-a2ca-2de2e6914f2a \ No newline at end of file +21c69fed-fb83-47c1-b0f1-55d632914a43 \ No newline at end of file diff --git a/data.ms/tasks/data.mdb b/data.ms/tasks/data.mdb old mode 100755 new mode 100644 index 821990c..221ef23 Binary files a/data.ms/tasks/data.mdb and b/data.ms/tasks/data.mdb differ diff --git a/data.ms/tasks/lock.mdb b/data.ms/tasks/lock.mdb old mode 100755 new mode 100644 index eb2d077..cd80b66 Binary files a/data.ms/tasks/lock.mdb and b/data.ms/tasks/lock.mdb differ diff --git a/db/.DS_Store b/db/.DS_Store new file mode 100644 index 0000000..e6bb1ea Binary files /dev/null and b/db/.DS_Store differ diff --git a/db/migrations/000011_create_emotes_table.down.sql b/db/migrations/000011_create_emotes_table.down.sql new file mode 100644 index 0000000..f4cc3a9 --- /dev/null +++ b/db/migrations/000011_create_emotes_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS emotes; \ No newline at end of file diff --git a/db/migrations/000011_create_emotes_table.up.sql b/db/migrations/000011_create_emotes_table.up.sql new file mode 100644 index 0000000..90e0dad --- /dev/null +++ b/db/migrations/000011_create_emotes_table.up.sql @@ -0,0 +1,5 @@ +CREATE TABLE emotes ( + "id" serial primary key not null, + "name" varchar not null, + "emote_id" varchar not null +) \ No newline at end of file diff --git a/db/migrations/000012_create_location_page_visit_counts.down.sql b/db/migrations/000012_create_location_page_visit_counts.down.sql new file mode 100644 index 0000000..e29d27d --- /dev/null +++ b/db/migrations/000012_create_location_page_visit_counts.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS location_page_visits; \ No newline at end of file diff --git a/db/migrations/000012_create_location_page_visit_counts.up.sql b/db/migrations/000012_create_location_page_visit_counts.up.sql new file mode 100644 index 0000000..f53ebc8 --- /dev/null +++ b/db/migrations/000012_create_location_page_visit_counts.up.sql @@ -0,0 +1,12 @@ +CREATE TABLE location_page_visits ( + id SERIAL PRIMARY KEY, + location_id INT NOT NULL REFERENCES locations(id), + week_key VARCHAR(10) NOT NULL, + visit_count BIGINT DEFAULT(0) NOT NULL, + is_deleted BOOLEAN, + updated_at TIMESTAMP DEFAULT NOW(), + + UNIQUE(location_id, week_key) +); + +CREATE INDEX idx_location_page_visits_week_key_visit_count ON location_page_visits(week_key, visit_count DESC); \ No newline at end of file diff --git a/db/mock/store.go b/db/mock/store.go index 576bfcc..2e35d26 100755 --- a/db/mock/store.go +++ b/db/mock/store.go @@ -13,7 +13,7 @@ import ( context "context" reflect "reflect" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" pgtype "github.com/jackc/pgx/v5/pgtype" gomock "go.uber.org/mock/gomock" ) diff --git a/db/sqlc/db.go b/db/repository/db.go similarity index 100% rename from db/sqlc/db.go rename to db/repository/db.go diff --git a/db/sqlc/error.go b/db/repository/error.go similarity index 100% rename from db/sqlc/error.go rename to db/repository/error.go diff --git a/db/sqlc/follow.sql.go b/db/repository/follow.sql.go similarity index 100% rename from db/sqlc/follow.sql.go rename to db/repository/follow.sql.go diff --git a/db/sqlc/images.go b/db/repository/images.go similarity index 100% rename from db/sqlc/images.go rename to db/repository/images.go diff --git a/db/sqlc/images.sql.go b/db/repository/images.sql.go similarity index 100% rename from db/sqlc/images.sql.go rename to db/repository/images.sql.go diff --git a/db/sqlc/locations.go b/db/repository/locations.go similarity index 100% rename from db/sqlc/locations.go rename to db/repository/locations.go diff --git a/db/sqlc/locations.sql.go b/db/repository/locations.sql.go similarity index 100% rename from db/sqlc/locations.sql.go rename to db/repository/locations.sql.go diff --git a/db/sqlc/models.go b/db/repository/models.go similarity index 100% rename from db/sqlc/models.go rename to db/repository/models.go diff --git a/db/sqlc/news_events.go b/db/repository/news_events.go similarity index 100% rename from db/sqlc/news_events.go rename to db/repository/news_events.go diff --git a/db/sqlc/news_events.sql.go b/db/repository/news_events.sql.go similarity index 100% rename from db/sqlc/news_events.sql.go rename to db/repository/news_events.sql.go diff --git a/db/sqlc/provinces.sql.go b/db/repository/provinces.sql.go similarity index 100% rename from db/sqlc/provinces.sql.go rename to db/repository/provinces.sql.go diff --git a/db/sqlc/querier.go b/db/repository/querier.go similarity index 100% rename from db/sqlc/querier.go rename to db/repository/querier.go diff --git a/db/sqlc/regencies.sql.go b/db/repository/regencies.sql.go similarity index 100% rename from db/sqlc/regencies.sql.go rename to db/repository/regencies.sql.go diff --git a/db/sqlc/regions.sql.go b/db/repository/regions.sql.go similarity index 100% rename from db/sqlc/regions.sql.go rename to db/repository/regions.sql.go diff --git a/db/sqlc/reviews.go b/db/repository/reviews.go similarity index 100% rename from db/sqlc/reviews.go rename to db/repository/reviews.go diff --git a/db/sqlc/reviews.sql.go b/db/repository/reviews.sql.go similarity index 100% rename from db/sqlc/reviews.sql.go rename to db/repository/reviews.sql.go diff --git a/db/sqlc/sessions.sql.go b/db/repository/sessions.sql.go similarity index 100% rename from db/sqlc/sessions.sql.go rename to db/repository/sessions.sql.go diff --git a/db/sqlc/store.go b/db/repository/store.go similarity index 100% rename from db/sqlc/store.go rename to db/repository/store.go diff --git a/db/sqlc/test/locations_test.go b/db/repository/test/locations_test.go similarity index 94% rename from db/sqlc/test/locations_test.go rename to db/repository/test/locations_test.go index c3ff104..eb2b995 100755 --- a/db/sqlc/test/locations_test.go +++ b/db/repository/test/locations_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/jackc/pgx/v5/pgtype" "github.com/stretchr/testify/require" diff --git a/db/sqlc/test/main_test.go b/db/repository/test/main_test.go similarity index 90% rename from db/sqlc/test/main_test.go rename to db/repository/test/main_test.go index 9f702e4..12ecc82 100755 --- a/db/sqlc/test/main_test.go +++ b/db/repository/test/main_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/jackc/pgx/v5/pgxpool" ) diff --git a/db/sqlc/test/users_test.go b/db/repository/test/users_test.go similarity index 89% rename from db/sqlc/test/users_test.go rename to db/repository/test/users_test.go index 4659173..0570eeb 100755 --- a/db/sqlc/test/users_test.go +++ b/db/repository/test/users_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" "github.com/stretchr/testify/require" ) diff --git a/db/sqlc/tx_location.go b/db/repository/tx_location.go similarity index 100% rename from db/sqlc/tx_location.go rename to db/repository/tx_location.go diff --git a/db/sqlc/users.go b/db/repository/users.go similarity index 100% rename from db/sqlc/users.go rename to db/repository/users.go diff --git a/db/sqlc/users.sql.go b/db/repository/users.sql.go similarity index 100% rename from db/sqlc/users.sql.go rename to db/repository/users.sql.go diff --git a/dev-meilisearch.sh b/dev-meilisearch.sh index e3bebb5..5959d4a 100755 --- a/dev-meilisearch.sh +++ b/dev-meilisearch.sh @@ -1,4 +1,5 @@ #! /bin/bash -meilisearch --master-key="12rchaaonetdadaaoenh" +meilisearch --http-addr 0.0.0.0:7700 --master-key="12rchaaonetdadaaoenh" + diff --git a/import_csv.sh b/import_csv.sh index b67081e..c8a85b0 100755 --- a/import_csv.sh +++ b/import_csv.sh @@ -2,7 +2,7 @@ cp ./db/csv_seeder/* /tmp/ # SEEDING MAIN DATAABSE -sudo -u postgres psql \ +sudo -u water psql \ -c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \ -c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \ -c '\copy provinces(id, province_name, region_id) FROM '"'/tmp/provinsi.csv'"' DELIMITER '"','"' CSV HEADER;' \ @@ -14,7 +14,7 @@ sudo -u postgres psql \ -d hiling_dev && # SEEDING TEST DATABASE -sudo -u postgres psql \ +sudo -u water psql \ -c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \ -c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \ -c '\copy provinces(id, province_name, region_id) FROM '"'/tmp/provinsi.csv'"' DELIMITER '"','"' CSV HEADER;' \ @@ -26,33 +26,33 @@ sudo -u postgres psql \ -d hiling_dev_test # FIXING SEQUENCES AFTER SEEDING -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'locations_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'locations_id_seq'"'))-1 FROM locations))' \ -d hiling_dev_test && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'users_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'users_id_seq'"'))-1 FROM users))' \ -d hiling_dev_test && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'reviews_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'reviews_id_seq'"'))-1 FROM reviews))' \ -d hiling_dev_test && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'images_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'images_id_seq'"'))-1 FROM images))' \ -d hiling_dev_test && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'tags_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'tags_id_seq'"'))-1 FROM tags))' \ -d hiling_dev_test && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'locations_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'locations_id_seq'"'))-1 FROM locations))' \ -d hiling_dev && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'users_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'users_id_seq'"'))-1 FROM users))' \ -d hiling_dev && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'reviews_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'reviews_id_seq'"'))-1 FROM reviews))' \ -d hiling_dev && - sudo -u postgres psql \ + sudo -u water psql \ -c 'SELECT setval('"'images_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'images_id_seq'"'))-1 FROM images))' \ -d hiling_dev && -sudo -u postgres psql \ +sudo -u water psql \ -c 'SELECT setval('"'tags_id_seq'"',(SELECT GREATEST(MAX(id)+1,nextval('"'tags_id_seq'"'))-1 FROM tags))' \ -d hiling_dev \ No newline at end of file diff --git a/main.go b/main.go index 9d49a95..4621e49 100755 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "log" "git.nochill.in/nochill/hiling_go/api" - db "git.nochill.in/nochill/hiling_go/db/sqlc" + db "git.nochill.in/nochill/hiling_go/db/repository" "git.nochill.in/nochill/hiling_go/util" _ "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" diff --git a/snapshots/data.ms.snapshot b/snapshots/data.ms.snapshot new file mode 100644 index 0000000..15e9da0 Binary files /dev/null and b/snapshots/data.ms.snapshot differ diff --git a/sqlc.yaml b/sqlc.yaml index 5c58eac..e9dfae8 100755 --- a/sqlc.yaml +++ b/sqlc.yaml @@ -7,7 +7,7 @@ sql: go: package: "db" sql_package: "pgx/v5" - out: "./db/sqlc" + out: "./db/repository" emit_json_tags: true emit_prepared_queries: false emit_interface: true diff --git a/util/.DS_Store b/util/.DS_Store new file mode 100644 index 0000000..a62752c Binary files /dev/null and b/util/.DS_Store differ