Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/streaming-exports' into streamin…
Browse files Browse the repository at this point in the history
…g-exports
  • Loading branch information
colinmegill committed Oct 22, 2024
2 parents 297471e + 8e627dd commit 30ef85e
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/bundlewatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Client components all use this version
- name: Use Node version for app builds
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -37,7 +37,7 @@ jobs:
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore npm cache directory
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
73 changes: 50 additions & 23 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,70 @@ concurrency:

on:
push:
branches: [edge]
paths-ignore: ["**.md"]
branches:
- edge
paths-ignore:
- "**.md"

pull_request:
paths-ignore: ["**.md"]
paths-ignore:
- "**.md"

jobs:
cypress-run:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and Run Application
uses: isbang/[email protected]
with:
compose-file: |
docker-compose.yml
docker-compose.test.yml
compose-flags: "--env-file test.env"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Check Application Health
uses: jtalk/url-health-check-action@v3
with:
url: http://localhost/api/v3/testConnection
max-attempts: 10
retry-delay: 10s
- name: Build and start Docker containers
run: |
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env up -d --build
- name: Dump Application Logs
if: failure()
- name: Wait for application to be ready
run: |
echo "Health check failed. Dumping Docker logs..."
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env logs
timeout=300
start_time=$(date +%s)
while true; do
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost/api/v3/testConnection)
if [ $response -eq 200 ]; then
echo "Application is ready!"
break
fi
current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for application to be ready. Dumping logs:"
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env logs
exit 1
fi
sleep 5
done
- name: Cypress Run
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/!(third-party)/**/*.cy.js
working-directory: e2e

- name: Upload Cypress screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: e2e/cypress/screenshots

- name: Upload Cypress videos
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: e2e/cypress/videos

- name: Stop Docker containers
if: always()
run: docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env down
6 changes: 3 additions & 3 deletions .github/workflows/depcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
echo "name=HAS_SECRET" >> $GITHUB_ENV
- name: Use Node.js
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v4
with:
node-version: 14.4.0
node-version: 18

# See: https://github.com/taskworld/commit-status
- name: Install commit-status CLI tool
Expand All @@ -39,7 +39,7 @@ jobs:
commit-status pending "DepCheck / dependencies" "Detecting unused packages..."
commit-status pending "DepCheck / devDependencies" "Detecting unused packages..."
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Install depcheck CLI tool
run: npm install -g depcheck
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v4
with:
node-version: 14.4.0
node-version: 18

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Restore npm cache directory
uses: actions/cache@v2.1.5
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
id: extract_branch

- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
ref: ${{ steps.extranct_branch.outputs.branch }}
ref: ${{ steps.extract_branch.outputs.branch }}

- name: Login to Docker Hub
uses: azure/docker-login@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
test-clj:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Prepare java
uses: actions/setup-java@v2.5.0
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 16.0.2

- name: Install Clojure tooling
uses: DeLaGuardo/setup-clojure@3.7
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 1.10.1.693

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Comment.propTypes = {
rejectButtonText: PropTypes.string,
isMetaCheckbox: PropTypes.bool,
comment: PropTypes.shape({
active: PropTypes.bool,
txt: PropTypes.string,
is_meta: PropTypes.bool
})
Expand Down
22 changes: 11 additions & 11 deletions server/src/routes/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import logger from "../utils/logger";
type Formatters<T> = Record<string, (row: T) => string>;
const sep = "\n";

const formatEscapedText = (s: string) => `"${s.replace(/"/g, '""')}"`;

function formatCSVHeaders<T>(colFns: Formatters<T>) {
return Object.keys(colFns).join(",");
}
Expand Down Expand Up @@ -67,16 +69,15 @@ async function loadConversationSummary(zid: number, siteUrl: string) {
};
const data = pca.asPOJO as PcaData;

const escapeQuotes = (s: string) => s.replace(/"/g, '""');
return [
["topic", `"${escapeQuotes(convo.topic)}"`],
["topic", formatEscapedText(convo.topic)],
["url", `${siteUrl}/${zinvite}`],
["voters", Object.keys(data["user-vote-counts"]).length],
["voters-in-conv", data["in-conv"].length],
["commenters", commenters],
["comments", data["n-cmts"]],
["groups", Object.keys(data["group-clusters"]).length],
["conversation-description", `"${escapeQuotes(convo.description)}"`],
["conversation-description", formatEscapedText(convo.description)],
].map((row) => row.join(","));
}

Expand Down Expand Up @@ -136,8 +137,9 @@ async function sendCommentSummary(zid: number, res: Response) {
(row) => {
const comment = comments.get(row.tid);
if (comment) {
if (row.vote === 1) comment.agrees += 1;
else if (row.vote === -1) comment.disagrees += 1;
// note that -1 means agree and 1 means disagree
if (row.vote === -1) comment.agrees += 1;
else if (row.vote === 1) comment.disagrees += 1;
else if (row.vote === 0) comment.pass += 1;
} else {
logger.warn(`Comment row not found for [zid=${zid}, tid=${row.tid}]`);
Expand All @@ -160,7 +162,7 @@ async function sendCommentSummary(zid: number, res: Response) {
agrees: (row) => String(row.agrees),
disagrees: (row) => String(row.disagrees),
moderated: (row) => String(row.mod),
"comment-body": (row) => String(row.txt),
"comment-body": (row) => formatEscapedText(row.txt),
},
commentRows
)
Expand All @@ -182,7 +184,7 @@ async function sendVotesSummary(zid: number, res: Response) {
datetime: (row) => formatDatetime(row.timestamp),
"comment-id": (row) => String(row.tid),
"voter-id": (row) => String(row.pid),
vote: (row) => String(row.vote),
vote: (row) => String(-row.vote), // have to flip -1 to 1 and vice versa
};
res.setHeader("Content-Type", "text/csv");
res.write(formatCSVHeaders(formatters) + sep);
Expand Down Expand Up @@ -278,10 +280,8 @@ async function sendParticipantVotesSummary(zid: number, res: Response) {
currentParticipantId = pid;
currentParticipantVotes.clear();
}

const tid: number = row.tid;
const vote: number = row.vote;
currentParticipantVotes.set(tid, vote);
// have to flip vote from -1 to 1 and vice versa
currentParticipantVotes.set(row.tid, -row.vote);
},
() => {
if (currentParticipantId != -1) {
Expand Down

0 comments on commit 30ef85e

Please sign in to comment.