Skip to content

Add more data to the dev seeds #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
945b6a3
Fix the tag updates atomicity and deadlocks
MareStare Mar 30, 2025
e72f7db
Replace `Map.drop()` with `Map.take()` as per Liam's feedback in DM
MareStare Mar 30, 2025
a7f4105
Fix error handling since there will be a tuple of more than 2 items r…
MareStare Mar 31, 2025
79c794c
Replace `+1` with `1` for update_images_counts
MareStare May 12, 2025
270825c
Rename `update_images_counts` to `update_image_counts` and replace `c…
MareStare May 12, 2025
343b6e1
Replace the capture operator with an explicit `fn tag_name ->`
MareStare May 12, 2025
1a601a9
Fix remove repo nil match autocompleted by Github Copilot (bruh)
MareStare May 12, 2025
e896931
Fix the grammar in autocomplete test context comment
MareStare Apr 2, 2025
9ca11b7
Use unique input names for search forms
mdashlw Apr 2, 2025
7d2cd0e
Reindex tag itself on "Rebuild index"
mdashlw Apr 2, 2025
56b0afa
Enclosing keyboard navigation test into describe block
koloml Apr 2, 2025
8288a3b
Added the test case for the keydown event with empty code
koloml Apr 2, 2025
8379df2
Fixed `Enter` key presses not being handled properly on Android devices
koloml Apr 2, 2025
0d3e94b
Uninstalled `eslint-plugin-vitest`
koloml Apr 2, 2025
d865b52
Bumped `typescript-eslint` from 8.17.0 to 8.29.0
koloml Apr 2, 2025
78e10b0
Installed `@vitest/eslint-plugin` 1.1.38
koloml Apr 2, 2025
e3a1b95
Replaced import from `eslint-plugin-vitest` to `@vitest/eslint-plugin`
koloml Apr 2, 2025
e941708
Moved `init()` directly to the `describe` block
koloml Apr 2, 2025
4fd8de8
Revert "Moved `init()` directly to the `describe` block"
koloml Apr 2, 2025
12959f8
Respect IP mask when looking up users
mdashlw Mar 24, 2025
6dcc50f
Log DNP entry transitions
mdashlw Mar 23, 2025
acbc01b
Preload tag in dnp transition controller
mdashlw Mar 24, 2025
f03de44
Update override display logic for tags
mdashlw Mar 3, 2025
6ce69a9
bump software versions
Meow Apr 4, 2025
725f57f
postgres17-client
Meow Apr 4, 2025
baaf40e
Bump vite in /assets
dependabot[bot] Apr 4, 2025
96611c9
improve dev seeds (wip)
Meow Jun 12, 2024
d1aae41
Format seeds_development.exs
MareStare Mar 27, 2025
3c3705e
prettier . -w
MareStare Mar 27, 2025
3dfdef9
Remove `seeds_development.json`
MareStare Mar 27, 2025
4ae1af4
fix dev seeds
Meow Sep 30, 2024
146af87
Fix script name in comment
MareStare Mar 27, 2025
e849e94
Remove clashing alias
MareStare Mar 27, 2025
3fcb1f5
Parallel image upload in dev seeds
MareStare Mar 29, 2025
bcf9b22
Create OpenSearch indices in parallel (doesn't give a significant boo…
MareStare Mar 30, 2025
dbf759c
Give away the temp file ownership to the image upload process, increa…
MareStare Mar 30, 2025
29d33de
Add `DROP_DB` config env var
MareStare Mar 31, 2025
0267e50
Ignore DB logs, but keep other logs
MareStare Apr 1, 2025
4e6c9ac
Use logger instead of IO.puts in seeds_development
MareStare Apr 1, 2025
ed3096c
Improve logging and error handling on objects.ex
MareStare Apr 2, 2025
eac7a36
Hide SQL and Exq logs by default
MareStare Apr 2, 2025
4a0d362
Parallelize the rest of the dev seeding
MareStare Apr 2, 2025
9da8406
Use logger in `seeds.exs`
MareStare Apr 3, 2025
8852e60
Preload all forums for seeding
MareStare Apr 5, 2025
c010dc0
Remove now useless `COPY` instructions because we use a volume bind-m…
MareStare Apr 5, 2025
0ae58d5
Add more topic name variety to reduce the probability of collisions
MareStare Apr 5, 2025
e3f4955
Add more context to topic name collision error
MareStare Apr 5, 2025
fd05700
Retry the seeding of a topic on name collision
MareStare Apr 5, 2025
a363ee5
Add more logs to the thumbnailer
MareStare Apr 5, 2025
d2103e6
Less noisy logs for seeding topics
MareStare Apr 5, 2025
93e4e39
Enable module metadata in dev logs for easier navigation
MareStare Apr 5, 2025
01e49fc
Remove unnecessary `[Thumbnails]` prefix now that module metadata is …
MareStare Apr 5, 2025
284558c
Add log filtering via `PHILOMENA_LOG` env var
MareStare Apr 5, 2025
673c577
Add `dev.sh` script wrapper over `docker compose`
MareStare Apr 5, 2025
2b8cc21
Reindex only images that were changed after generating comments
MareStare Apr 5, 2025
c227a4b
approve_comment already reindexes the comment
MareStare Apr 5, 2025
1bc362d
Display new uploads immediately once their thumbnails were generated …
MareStare Apr 5, 2025
a8fe3bc
Use uppercase env var name for DROP_DB
MareStare Apr 5, 2025
c87e7dd
Add a FIXME about the pagination bug with low activity
MareStare Apr 5, 2025
d5196d1
Fix an type error in objects.ex and increase logs verbosity level for…
MareStare Apr 6, 2025
2b12042
Fix a comment
MareStare Apr 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
import_deps: [:ecto, :phoenix],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
inputs: ["*.{ex,exs}", "priv/*/seeds*.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
2 changes: 1 addition & 1 deletion assets/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tsEslint from 'typescript-eslint';
import vitestPlugin from 'eslint-plugin-vitest';
import vitestPlugin from '@vitest/eslint-plugin';
import globals from 'globals';

export default tsEslint.config(
Expand Down
4 changes: 2 additions & 2 deletions assets/js/autocomplete/__tests__/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GetTagSuggestionsResponse, TagSuggestion } from 'autocomplete/client';
* `jsdom`, so it's expected that you define a single test per file so that
* `vitest` runs every test in an isolated process, where no cleanup is needed.
*
* I wish `vitest` actually did that by default, because cleanup logic and test
* I wish `vitest` actually did that by default, because cleanup logic and
* in-process test isolation is just boilerplate that we could avoid at this
* scale at least.
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ export class TestContext {
await vi.runAllTimersAsync();
}

async keyDown(code: string, params?: { ctrlKey?: boolean }) {
async keyDown(code: string, params?: { ctrlKey?: boolean; key?: string }) {
fireEvent.keyDown(this.input, { code, ...(params ?? {}) });
await vi.runAllTimersAsync();
}
Expand Down
258 changes: 145 additions & 113 deletions assets/js/autocomplete/__tests__/keyboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,114 +1,146 @@
import { init } from './context';

it('supports navigation via keyboard', async () => {
const ctx = await init();

await ctx.setInput('f');

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [
"👉 forest 3",
"force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "force field<>",
"suggestions": [
"forest 3",
"👉 force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('ArrowDown', { ctrlKey: true });

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "flower<>",
"suggestions": [
"forest 3",
"force field 1",
"fog 1",
"👉 flower 1",
],
}
`);

await ctx.keyDown('ArrowUp', { ctrlKey: true });

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [
"👉 forest 3",
"force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('Enter');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [],
}
`);

await ctx.setInput('forest, t<>, safe');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, t<>, safe",
"suggestions": [
"artist:test 1",
],
}
`);

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [
"👉 artist:test 1",
],
}
`);

await ctx.keyDown('Escape');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [],
}
`);

await ctx.setInput('forest, t<>, safe');
await ctx.keyDown('ArrowDown');
await ctx.keyDown('Enter');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [],
}
`);
import { init, TestContext } from './context';

describe('Autocomplete keyboard navigation', () => {
let ctx: TestContext;

beforeAll(async () => {
ctx = await init();
});

it('supports navigation via keyboard', async () => {
await ctx.setInput('f');

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [
"👉 forest 3",
"force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "force field<>",
"suggestions": [
"forest 3",
"👉 force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('ArrowDown', { ctrlKey: true });

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "flower<>",
"suggestions": [
"forest 3",
"force field 1",
"fog 1",
"👉 flower 1",
],
}
`);

await ctx.keyDown('ArrowUp', { ctrlKey: true });

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [
"👉 forest 3",
"force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('Enter');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [],
}
`);

await ctx.setInput('forest, t<>, safe');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, t<>, safe",
"suggestions": [
"artist:test 1",
],
}
`);

await ctx.keyDown('ArrowDown');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [
"👉 artist:test 1",
],
}
`);

await ctx.keyDown('Escape');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [],
}
`);

await ctx.setInput('forest, t<>, safe');
await ctx.keyDown('ArrowDown');
await ctx.keyDown('Enter');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest, artist:test<>, safe",
"suggestions": [],
}
`);
});

it('should handle Enter key presses with empty code property', async () => {
await ctx.setInput('f');

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "f<>",
"suggestions": [
"forest 3",
"force field 1",
"fog 1",
"flower 1",
],
}
`);

await ctx.keyDown('ArrowDown');
await ctx.keyDown('', { key: 'Enter' });

ctx.expectUi().toMatchInlineSnapshot(`
{
"input": "forest<>",
"suggestions": [],
}
`);
});
});
20 changes: 14 additions & 6 deletions assets/js/autocomplete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { LocalAutocompleter } from '../utils/local-autocompleter';
import * as history from './history';
import { AutocompletableInput, TextInputElement } from './input';
import {
SuggestionsPopupComponent,
Suggestions,
TagSuggestionComponent,
Suggestion,
HistorySuggestionComponent,
ItemSelectedEvent,
Suggestion,
Suggestions,
SuggestionsPopupComponent,
TagSuggestionComponent,
} from '../utils/suggestions-view';
import { prefixMatchParts } from '../utils/suggestions-model';
import { $$ } from '../utils/dom';
Expand Down Expand Up @@ -243,13 +243,21 @@ class Autocomplete {
if (!this.isActive() || this.input.element !== event.target) {
return;
}
if ((event.key === ',' || event.code === 'Enter') && this.input.type === 'single-tag') {

let keyCode = event.code;

// Chrome & Firefox on Android devices return empty code when "Enter" is pressed.
if (!keyCode && event.key === 'Enter') {
keyCode = event.key;
}

if ((event.key === ',' || keyCode === 'Enter') && this.input.type === 'single-tag') {
// Comma/Enter mean the end of input for the current tag in single-tag mode.
this.hidePopup(`The user accepted the existing input via key: '${event.key}', code: '${event.code}'`);
return;
}

switch (event.code) {
switch (keyCode) {
case 'Enter': {
const { selectedSuggestion } = this.popup;
if (!selectedSuggestion) {
Expand Down
Loading