Skip to content
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

feat: add where function to dt-reports class #2484

Merged
merged 5 commits into from
Jun 27, 2024

Conversation

squigglybob
Copy link
Collaborator

Adds functionality to the class in dt-reports.php to find reports where some things are true.

@squigglybob
Copy link
Collaborator Author

@corsacca I've added in this function so I can pull out reports that only match on certain fields.

I'm thinking actually that this could be more powerful if it mimicked something like laravels where function where you can add in comparison functions.

so instead of an assosciative array which assumes equality in the where clause, it would have an array of arrays

Disciple_Tools_Reports::where( [
   [ 'column_name', '=', $value ],
] );

and the middle value of the array could also be '!=', '>', '<', 'not' etc.

dt-reports/reports.php Outdated Show resolved Hide resolved
@squigglybob
Copy link
Collaborator Author

squigglybob commented May 22, 2024

Are there any other changes that need to be made in light of our recent conversation about keeeping things consistent? @corsacca

@corsacca
Copy link
Member

hey @squigglybob

Disciple_Tools_Reports::where( [
   [ 'column_name', '=', $value ],
] );

This does not seem to match the code.

We also talked about matching the format in https://developers.disciple.tools/theme-core/api-posts/list-query

@squigglybob
Copy link
Collaborator Author

hey @squigglybob

Disciple_Tools_Reports::where( [
   [ 'column_name', '=', $value ],
] );

That was an example of how I was thinking it could be. It's not currently how it works.

This does not seem to match the code.

We also talked about matching the format in https://developers.disciple.tools/theme-core/api-posts/list-query

That was the thing I was thinking of. I'll look at getting it matching that format next

@squigglybob
Copy link
Collaborator Author

@corsacca hey bro, when you're back in the saddle, it would be good to connect on this one.

Currently the where function matches the list_posts search and query for the very simple cases (except for putting the values inside an array, which could be coded to cope with string/array depending on what result is desired)

could we merge this one in, and I can create a new ticket to upgrade the where clause to have more of the complicated features like ORing etc.

The reports table and posts are quite different in the way they work, so it would be good to talk through exactly how we want the search query params to work.

@corsacca
Copy link
Member

@squigglybob

The function name where seems a bit confusion. Maybe we use: list_reports() instead.

The current format for the $args or $where is:

[ 'post_id' => 3, 'type' => 'key' ]

@todo, add a comment for expected args format

This format does not support the expansion of the operations ( '!=', '>', '<', 'not' etc. )
So when/if we do want to add them we'd need to refactor the args and change the places using the function across multiple plugins.

I'd rather we build this out nicely. We can use direct $wpdb calls until it is done, which might be simpler anyways.

…list

putting the value in an array will mean we can add operators and other upgrades to how the where works later
@squigglybob
Copy link
Collaborator Author

@corsacca I should have implemented what we talked about straight away. 😬 Hopefully I remembered what we talked about
Should be done if i did 😁

@corsacca
Copy link
Member

Thanks @squigglybob!

@corsacca corsacca merged commit a8ac58a into develop Jun 27, 2024
4 checks passed
@corsacca corsacca deleted the feat/dt-reports/added-functionality branch June 27, 2024 10:48
micahmills added a commit that referenced this pull request Sep 13, 2024
…#2558)

* moves component services to header

* SSO: uncomment recaptcha check, save SSO methods used in user meta(#2518)

* chore: uncomment recaptcha check in backend

* feat: save a list of sign in providers

* Add color variables to css (#2516)

* add color variables to css

This allows their easy re-use within plugins

* update from style guide

* rebuild styles

* Fix errors saving dropdown option translations (#2513)

* fix parsing of option translation locale

* don't reset option label upon saving translation

* Fix translations on field option labels from being overwritten.
Fix saving custom label over default translated label.

* phpcs

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Translated using Weblate (Croatian) (#2520)

Currently translated at 99.8% (1206 of 1208 strings)

Translated using Weblate (Swahili)

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Swahili)

Currently translated at 83.5% (1009 of 1208 strings)

Translated using Weblate (French (fr_FR))

Currently translated at 85.5% (1034 of 1208 strings)

Translated using Weblate (Italian (it_IT))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Croatian)

Currently translated at 99.9% (1207 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 99.9% (1207 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 99.9% (1207 of 1208 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.







Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/bs_BA/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/fr_FR/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/hr/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/sw/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>
Co-authored-by: Paul Bruss <mosquitoacres@gmail.com>
Co-authored-by: Zlatko Celik <zlatko.celik@gmail.com>

* Disciple.Tools v1.64

* User Profile: Ensure user display name is maintained (#2521)

* D.T Reports: add list function to dt-reports class (#2484)

* feat: add where function to dt-reports class

* feat: return error if wrong value type is given

* feat: move value of where clause into array; refactor: where name to list

putting the value in an array will mean we can add operators and other upgrades to how the where works later

* Workflows: Ensure connection fields trigger associated workflow execution (#2522)

* Settings D.T: limit number for users listed in base user select

* Workflows: Added custom Comments action (#2517)

* Added custom Comments action to workflows

* Prevents comments from being added multiple times

* Resolved comments

* code styles fixes

* Removed comments from step 2

* Ran prettier

* Metrics - Personal - Gen-Map - Restrict To Records Responsible For (#2504)

* Ensure to only restrict to records user is responsible for

* Filter accordingly by slug & post type

* Simplified query results generation logic

* Removed unwanted write log statement

* Ensure record node shares are forced for administrators

* Access to view all records can view entire tree. Multipliers can see the name of their own record.

* #2496 - Select & Tags Cumulative Activity Metrics Charts (#2514)

* Select & tags cumulative activity metrics charts

* UI tweaks & end of time range cumulative total matches

* Improved modal count mismatches

* Added pm.meta_value group by to updated month sql

* wording

* Cleaned up stale code blocks

* Cleaned up straggling stale code blocks

* Check for create_users permission when displaying Add User submenu (#2530)

* Translated using Weblate (Swahili) (#2531)

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Italian (it_IT))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 100.0% (1208 of 1208 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.





Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/bs_BA/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/sw/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>

* Disciple.Tools v1.65.0

* Fix personal genmap access to records

* Custom password reset flow: Clear user cache when saving the reset key

* Fix email headers and login template errors (#2534)

* fix: add content-type: text/html correctly if headers is a string

fix: deal with  being a string when checking for content-type: text/html

* fix: Undefined array key 0 in login-user-manager

* phpcs

* Metrics: Collapse field selects down to a single row (#2533)

* SOO Login: fix issue where email wasn't being captured

* Metrics - Genmapper - Show Data Layers (#2515)

* Introduced data layer field filters for generational tree metrics

* Addressed sql placeholders code smells

* Ignore string array escaping

* Revised ui and data layer flow logic

* Introduced displaying of field icons

* Added switch to toggle between labels and icons

* wording

* Enforce data layer display ordering

* Hide data layer settings by default + Also display status field label

* Plus icon count for each field line + White icons with fixed size

* Ensure mdi font icons default to white

* SSO Login: setting to persist login (#2537)

* SOO Login: setting to persist login

* phpcs

* phpcs

* Metrics > Genmapper: fix icon sizing and alignment (#2539)

* Template integration in dt-modal of duplicate detected button

* Customizations: Fix tile label translations and clearing field translations (#2550)

* Customizations: Fix tile label translations and clearing field translations

* revert phpcs

* #1873 - Default Reply To On Email Notifications (#2545)

* Default reply-to on email notifications

* Wording and order

* Don't overwrite existing reply to values

* Change default email name and address

* revert phpcs

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Admin Actions integration on edit page.

* Workflow action: Comment replace user or connection tokens with values (#2541)

* Comments {subassigned} functionality

* removed hardcoded {connections}

* PR cleanup/optimizations

* Copied Jon's Fixes

* Customizations: Resolved missing permissions on role updates bug (#2552)

* SSO Login: allow logging in with firebase ID when email is not provided. (#2536)

* SOO Login: allow logging in with firebase ID when email is not provided.

* phpcs

* fix typo

* #2523 - Ensure Geocoded Locations Are Copied When Transferring Contact To Another Instance (#2525)

* Ensure geocoded locations are copied when transferring contact to another instance

* Transfer additional geolocation grid meta info

* Transfer actual grid meta to be used + Avoid duplicate location_grid values

* Add by pre-defined meta grid values

* Reverted posts.php auto formatting

* Reverted contacts-transfer.php auto formatting

* Undefined error fix

* revert structure change

* allow dup locations

* Translated using Weblate (Italian (it_IT)) (#2556)

Currently translated at 100.0% (1209 of 1209 strings)

Translated using Weblate (Arabic)

Currently translated at 83.3% (1008 of 1209 strings)

Translated using Weblate (Vietnamese)

Currently translated at 100.0% (1209 of 1209 strings)

Translated using Weblate (Vietnamese)

Currently translated at 85.7% (1037 of 1209 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translated using Weblate (French (fr_FR))

Currently translated at 85.6% (1035 of 1208 strings)






Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/ar/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/fr_FR/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/vi/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Charlie Ritchie <ritchiecharlie@gmail.com>
Co-authored-by: Corsacca <corsacca@gmail.com>
Co-authored-by: FarahDoumani <farahdoumani@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>

* Disciple.Tools v1.66

* removed unwanted code and added comments

* corrected heading and styling duplicate detected

* Metrics - Personal Layers Map (#2542)

* Support record maps within personal metrics

* Embedded filter by post id sql + Split local storage cookie across menu slugs

* Updated sql to ensure only shared records are returned

* Resolved auto formatting issue

* Additional tidy-ups

* Simplified sql

* Ensure metrics is only shown for specific user roles

* Personal for all. Dynamics by permissions

* Prevent non-slug related requests

* Moved permissions check to endpoint

* Revised permission checks + Updated genmap to follow new checks

* Lists: Split By - Option To Clear Filters (#2544)

* Display current filter labels

* Deleted console logs

* Ignore sorting labels

* Support multiple split-by filters with dynamic count refreshes

* Avoid auto filter refreshes on split by option selections

* Enforce overwriting of previously selected field options

* PHPCS - Upgrade WP-Coding Standards To v3 (#2546)

* Updated to v3.1.0

* Introduced additional rules to reduce error counts

* Further reduced sniff exceptions

* Resolved remaining exceptions

* Revert "Resolved remaining exceptions"

This reverts commit f5103bb.

* fix MultiLineFunctionDeclaration errors

* remove some rules

* remove commented excludes

* enable Generic.WhiteSpace.IncrementDecrementSpacing

* enable Universal.Arrays.DuplicateArrayKey

* enable Universal.WhiteSpace.CommaSpacing

* enable NormalizedArrays.Arrays.ArrayBraceSpacing

* enable PSR2.Classes.ClassDeclaration

* enable PSR2.Files.EndFileNewline

* enable Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence

* enable PSR2.Methods.FunctionClosingBrace

* enable WordPress.DB.PreparedSQL

* enable WordPress.Security.NonceVerification

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Only set D.T base email name and email address if none other is set (#2562)

* feat: add a hook when deleting a post (#2568)

* feat: add before post deleted hook (#2569)

* phpcbf

* fixes camel case error

* phpcs fix

* phpcs fixes for proper snake case

* prettier styling fixes

* gulp build files

---------

Co-authored-by: Micah Mills <micahmills@gmail.com>
Co-authored-by: squigglybob <squigglybob@users.noreply.github.com>
Co-authored-by: cairocoder01 <44169599+cairocoder01@users.noreply.github.com>
Co-authored-by: corsac <corsacca@gmail.com>
Co-authored-by: discipletoolsbot <115006603+discipletoolsbot@users.noreply.github.com>
Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>
Co-authored-by: Paul Bruss <mosquitoacres@gmail.com>
Co-authored-by: Zlatko Celik <zlatko.celik@gmail.com>
Co-authored-by: kodinkat <me@karlkatewu.com>
Co-authored-by: jlamanskygitt <125215675+jlamanskygitt@users.noreply.github.com>
Co-authored-by: brady-lamansky-gtt <125215973+brady-lamansky-gtt@users.noreply.github.com>
Co-authored-by: Charlie Ritchie <ritchiecharlie@gmail.com>
Co-authored-by: FarahDoumani <farahdoumani@gmail.com>
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.

2 participants