Skip to content

877 Odstranit nepotřebné filtry aktivity pro zrychlení načítání programu #688

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jaroslavtyc
Copy link
Contributor

Pro načtení aktivity z SQL používáme jedinou funkci zWhere, která za ta léta nastřádala spoustu balastu.

V tomto PR zahazuju ze základní query všechno, co není důležité vždy a rozšíření dotazu přenáším do konkrétních míst.

@jaroslavtyc jaroslavtyc requested review from Adrijaned and Copilot July 2, 2025 07:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes legacy, always-applied activity filters from the central zWhere query and pushes each filter into the specific callers for improved performance. It also modernizes method signatures, renames methods for clarity, and updates SQL-building to use structured constants.

  • Moved generic SQL filters out of base methods into individual call sites (e.g. in zFiltru, admin scripts, reports).
  • Renamed and refactored methods to return domain objects instead of booleans (maVolnomaKoliziSJinouAktivitou) and added precise return types.
  • Updated PHP syntax with typed properties, trailing commas, parameter types, and replaced magic strings with SQL-structure constants.

Reviewed Changes

Copilot reviewed 33 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Db/AbstractTestDb.php Clear query cache after rollback
tests/Aktivity/UzivatelMaVolnoTest.php Adapt tests to new maKoliziSJinouAktivitou return type
tests/Aktivity/ProbihaRegistraceAktivitTrait.php Switch to named-argument constructor calls
tests/Aktivity/AktivitaTymovePrihlasovaniTest.php Add trailing commas, adjust closure formatting
model/uzivatel.php Rename maVolno, update return types and filter constants
model/report.php Add optional mysqli, update helper methods
model/funkce/fw-database.php Strengthen type hints, unify mysqli handling
model/db-object.php Enhance generic zIds and caching, refine dotaz syntax
model/SystemoveNastaveni/SystemoveNastaveni.php Factor out database-dependent cache directory
model/PrednacitaniTrait.php Add explicit return types and argument typing
model/Cache/CachedDb.php Sort related tables before version comparison
model/Aktivita/Program.php Use SQL-structure constants, rename array keys (delka)
model/Aktivita/OnlinePrezence/OnlinePrezenceTestovaciAktivity.php Use SQL-structure constants for ordering
model/Aktivita/FiltrAktivity.php Remove unused constant
admin/scripts/.../prihlaseni.php Rewrite raw SQL to named joins
admin/scripts/.../mistnosti.php Use SQL-structure constants for table names
admin/scripts/.../zazemi-*.php Inline $rocnik instead of placeholder binding
admin/files/design/styl.css Reduce padding and font-size for error blocks
docker-compose.yml Shorten healthcheck timeout and start_period
migrace/.../DbMigrations.php Track endless migrations per session
Comments suppressed due to low confidence (2)

model/uzivatel.php:998

  • [nitpick] The docblock for maKoliziSJinouAktivitou correctly states @return Aktivita|null, but the parameter descriptions above still mention boolean semantics. Consider updating or removing outdated param docs.
     */

admin/scripts/modules/aktivity/mistnosti.php:35

  • You're using LokaceSqlStruktura::NAZEV but imported only AkceLokaceSqlStruktura. Either import the correct struct or switch to AkceLokaceSqlStruktura::NAZEV.
    dbInsertUpdate(AkceLokaceSqlStruktura::AKCE_LOKACE_TABULKA, [LokaceSqlStruktura::NAZEV => 'Nová místnost ' . $poradi, LokaceSqlStruktura::PORADI => $poradi]);

@@ -10,9 +14,8 @@
FROM akce_seznam
LEFT JOIN akce_seznam AS ostatni_akce_seznam ON akce_seznam.patri_pod IS NOT NULL AND akce_seznam.patri_pod = ostatni_akce_seznam.patri_pod
LEFT JOIN akce_lokace ON akce_lokace.id_lokace = COALESCE(ostatni_akce_seznam.lokace, akce_seznam.lokace)
WHERE akce_seznam.vybaveni != '' AND akce_seznam.rok = $1
WHERE akce_seznam.vybaveni != '' AND akce_seznam.rok = {$rocnik}
Copy link
Preview

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interpolating {$rocnik} directly into SQL can lead to maintenance issues; prefer parameter binding (e.g. WHERE rok = $1, [0 => $rocnik]) for consistency and safety.

Copilot uses AI. Check for mistakes.

@jaroslavtyc jaroslavtyc force-pushed the 877-zahodit-nepotrebne-sql-filtry-aktivity branch 3 times, most recently from 85106ea to e77d140 Compare July 4, 2025 06:04
@jaroslavtyc jaroslavtyc force-pushed the 877-zahodit-nepotrebne-sql-filtry-aktivity branch from e77d140 to 35b9027 Compare July 23, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant