Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

268 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚩 Flag123

12.3 계엄배 μ²œν•˜μ œμΌ μž¬κΈ°λ°œλž„ κΉƒλ°œλŒ€νšŒ by 민주주의 ν•΄λ°©μ „μ„  λ‚˜λ§Œ κΉƒλ°œ μ—†μ—‰ 총연맹

"12.3 계엄배 μ²œν•˜μ œμΌκΉƒλ°œλŒ€νšŒ" 😊 μš΄μ˜μžμž…λ‹ˆλ‹€.
μ˜¬λ €μ£Όμ‹  사진을 μ•„λž˜ λŒ€νšŒ μ‹Έμ΄νŠΈ(🌐 https://f.diginori.com)에 μ—…λ‘œλ“œν–ˆμŠ΅λ‹ˆλ‹€.
ν˜Ήμ‹œ λ¬Έμ œκ°€ 될 경우 말씀해(𝕏:samdulshop) μ£Όμ‹œλ©΄ μ¦‰μ‹œ μ‚­μ œν•˜λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€.
κ°μ‚¬ν•©λ‹ˆλ‹€.

πŸ“ Initial Dummy Data

SELECT version();
PostgreSQL 15.10 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
-- https://hub.docker.com/layers/library/postgres/15.10/images/sha256-6bd528fd9ed2ca50c0dd7c85c1bc20d0150c63418a04d8d3973cab95f63f9567

-- CREATE TABLE => postgres_init/1-create-table.sql

\d+ flags


INSERT INTO flags (name, latitude, longitude, img_url) VALUES
('#BRAT impeachment and it’s completely different but also still impeachment', 
37.525307 + (37.530139 - 37.525307) * RANDOM(), 
126.919467 + (126.922896 - 126.919467) * RANDOM(), 
'/dummy/d1.webp')

INSERT INTO flags (name, latitude, longitude, img_url) VALUES
('#BRAT impeachment and it’s completely different but also still impeachment', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d1.webp'),
('Korean branch of the Jedi Federation', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d2.webp'),
('Rapping Rabbit Federation', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d3.webp'),
('National Carrot Alliance Loving Rabbits', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/d4.webp'),
('Flags World Championship', 37.525307 + (37.530139 - 37.525307) * RANDOM(), 126.919467 + (126.922896 - 126.919467) * RANDOM(), '/dummy/FWC.png');


SELECT id,name,img_url FROM flags ORDER BY id DESC;

SELECT
    id,
    flag_id,
    delta_cnt,
    created_at AT TIME ZONE 'Asia/Seoul' AS created_at_kst
FROM 
    flag_like_history
ORDER BY 
    id DESC;

SHOW TIME ZONE; -- GMT

SELECT CURRENT_TIMESTAMP;

-- μͺΌμΈ
SELECT 
    f.id,
    f.name,
    f.img_url,
    COALESCE(SUM(fl.delta_cnt), 0) AS like_count
FROM 
    flags f
LEFT JOIN 
    flag_like_history fl
ON 
    f.id = fl.flag_id
GROUP BY 
    f.id, f.name, f.img_url
ORDER BY 
    f.id DESC

🌱 Env

  • Rename env.dummy to .env.local. Make sure the file is not pushed to the public GitHub repository.
  • To avoid using analytics and statistics by connecting to Google Firebase, delete analytics.ts.
  • Refer to the Vercel CLI to sync variables for database connection.
  • I used https://api.imgbb.com/ for image uploads. In your case, you should obtain a new API key

πŸ’» Local Run

  • ested on WSL Ubuntu 22.04.4 LTS and macOS. ( node : v20.17.0 || v22.12.0, nextjs : 14.2.19)
$ npm install
$ npm run dev

Test

$ npx jest -t "should correctly join URL parts into a complete URL"
 PASS  __tests__/utils.test.ts (5.773 s)
-----------------|---------|----------|---------|---------|----------------------------------------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                  
-----------------|---------|----------|---------|---------|----------------------------------------------------
All files        |   22.42 |      100 |    9.09 |   22.42 |                                                    
 app/lib         |   54.54 |      100 |       0 |   54.54 |                                                    
  getClientId.ts |   54.54 |      100 |       0 |   54.54 | 7-11                                               
 lib             |   18.75 |      100 |      10 |   18.75 |                                                    
  utils.ts       |   18.75 |      100 |      10 |   18.75 | 5-7,9-16,18-23,25-27,29-40,44-72,74-82,84-87,89-92 
-----------------|---------|----------|---------|---------|----------------------------------------------------

Test Suites: 1 skipped, 1 passed, 1 of 2 total
Tests:       3 skipped, 1 passed, 4 total
Snapshots:   0 total
Time:        6.379 s, estimated 10 s
Ran all test suites with tests matching "should correctly join URL parts into a complete URL"

$ npm test

🀝 Contribution

  • Contributions are open, though I don’t expect anyone to take an interest. I’ll gratefully accept any small advice or help. Thank you. Best regards. πŸ˜ŠπŸ‘
  • Data.ts has a UPDATA syntax to verify the caching of vercel. Most of the time, it's not necessary. If it's alive, you can delete it.
// https://nextjs.org/docs/app/building-your-application/data-fetching/fetching
const getDbData = unstable_cache(
  async () => {

    // TODO DISABLE
    await sql`
        UPDATE select_count
        SET count = count + 1, last_updated = now()
        WHERE id = 1;
      `;

    const data = await sql<Flag>`SELECT id, name, img_url FROM flags ORDER BY id DESC`;
    return data.rows;
  },
  ['msi'],
  {
    revalidate: CACHE_TIMEOUT,
    tags: ['ism']
  }
)

πŸš€ Deploy & Connect DB

βš“ Dockerizing

$ docker build -t flag123:1.1.0 .

$ docker images                  
REPOSITORY                   TAG       IMAGE ID       CREATED         SIZE
flag123                      1.1.0     09e5616462d9   2 minutes ago   179MB

$ docker run --name f110 -p 3110:3000 -d --env-file .env.local flag123:1.1.0

$ docker stats
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT     MEM %     NET I/O     BLOCK I/O   PIDS
8de21b110d7f   f110      0.00%     28.91MiB / 9.717GiB   0.29%     876B / 0B   0B / 0B     11

Docker Compose

# docker compose down --volumes --remove-orphans
# sudo rm -rf postgres_data

$ docker compose up -d db adminer
$ docker compose build web
$ docker compose up -d web

πŸ”– Ref

Errors

  • Application error: a client-side exception has occurred (see the browser console for more information).

About

A gallery of satirical flags created by citizens in response to the December 3, 2024 martial law declaration in South Korea.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages