Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Feeds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Feeds
Commits
cfc31fc6
Commit
cfc31fc6
authored
3 years ago
by
Andrew Dolgov
Browse files
Options
Downloads
Patches
Plain Diff
set annotations/types in af_psql_trgm
parent
d17b7931
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/af_psql_trgm/init.php
+14
-19
14 additions, 19 deletions
plugins/af_psql_trgm/init.php
with
14 additions
and
19 deletions
plugins/af_psql_trgm/init.php
+
14
−
19
View file @
cfc31fc6
...
@@ -202,7 +202,7 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -202,7 +202,7 @@ class Af_Psql_Trgm extends Plugin {
<?php
<?php
/* cleanup */
/* cleanup */
$enabled_feeds
=
$this
->
filter_unknown_feeds
(
$enabled_feeds
=
$this
->
filter_unknown_feeds
(
$this
->
get_stored_array
(
"enabled_feeds"
));
$this
->
host
->
get_array
(
$this
,
"enabled_feeds"
));
$this
->
host
->
set
(
$this
,
"enabled_feeds"
,
$enabled_feeds
);
$this
->
host
->
set
(
$this
,
"enabled_feeds"
,
$enabled_feeds
);
?>
?>
...
@@ -227,7 +227,7 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -227,7 +227,7 @@ class Af_Psql_Trgm extends Plugin {
}
}
function
hook_prefs_edit_feed
(
$feed_id
)
{
function
hook_prefs_edit_feed
(
$feed_id
)
{
$enabled_feeds
=
$this
->
get_stored_array
(
"enabled_feeds"
);
$enabled_feeds
=
$this
->
host
->
get_array
(
$this
,
"enabled_feeds"
);
?>
?>
<header>
<?=
__
(
"Similarity (af_psql_trgm)"
)
?>
</header>
<header>
<?=
__
(
"Similarity (af_psql_trgm)"
)
?>
</header>
...
@@ -244,7 +244,7 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -244,7 +244,7 @@ class Af_Psql_Trgm extends Plugin {
}
}
function
hook_prefs_save_feed
(
$feed_id
)
{
function
hook_prefs_save_feed
(
$feed_id
)
{
$enabled_feeds
=
$this
->
get_stored_array
(
"enabled_feeds"
);
$enabled_feeds
=
$this
->
host
->
get_array
(
$this
,
"enabled_feeds"
);
$enable
=
checkbox_to_sql_bool
(
$_POST
[
"trgm_similarity_enabled"
]
??
""
);
$enable
=
checkbox_to_sql_bool
(
$_POST
[
"trgm_similarity_enabled"
]
??
""
);
$key
=
array_search
(
$feed_id
,
$enabled_feeds
);
$key
=
array_search
(
$feed_id
,
$enabled_feeds
);
...
@@ -273,7 +273,7 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -273,7 +273,7 @@ class Af_Psql_Trgm extends Plugin {
if
(
!
$enable_globally
&&
if
(
!
$enable_globally
&&
!
in_array
(
$article
[
"feed"
][
"id"
],
!
in_array
(
$article
[
"feed"
][
"id"
],
$this
->
get_stored_array
(
"enabled_feeds"
)))
{
$this
->
host
->
get_array
(
$this
,
"enabled_feeds"
)))
{
return
$article
;
return
$article
;
}
}
...
@@ -281,14 +281,14 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -281,14 +281,14 @@ class Af_Psql_Trgm extends Plugin {
$similarity
=
(
float
)
$this
->
host
->
get
(
$this
,
"similarity"
,
$this
->
default_similarity
);
$similarity
=
(
float
)
$this
->
host
->
get
(
$this
,
"similarity"
,
$this
->
default_similarity
);
if
(
$similarity
<
0.01
)
{
if
(
$similarity
<
0.01
)
{
Debug
::
log
(
"af_psql_trgm: similarity is set too low (
$similarity
)"
,
Debug
::
$
LOG_EXTENDED
);
Debug
::
log
(
"af_psql_trgm: similarity is set too low (
$similarity
)"
,
Debug
::
LOG_EXTENDED
);
return
$article
;
return
$article
;
}
}
$min_title_length
=
(
int
)
$this
->
host
->
get
(
$this
,
"min_title_length"
,
$this
->
default_min_length
);
$min_title_length
=
(
int
)
$this
->
host
->
get
(
$this
,
"min_title_length"
,
$this
->
default_min_length
);
if
(
mb_strlen
(
$article
[
"title"
])
<
$min_title_length
)
{
if
(
mb_strlen
(
$article
[
"title"
])
<
$min_title_length
)
{
Debug
::
log
(
"af_psql_trgm: article title is too short (min:
$min_title_length
)"
,
Debug
::
$
LOG_EXTENDED
);
Debug
::
log
(
"af_psql_trgm: article title is too short (min:
$min_title_length
)"
,
Debug
::
LOG_EXTENDED
);
return
$article
;
return
$article
;
}
}
...
@@ -327,10 +327,10 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -327,10 +327,10 @@ class Af_Psql_Trgm extends Plugin {
$row
=
$sth
->
fetch
();
$row
=
$sth
->
fetch
();
$similarity_result
=
$row
[
'ms'
];
$similarity_result
=
$row
[
'ms'
];
Debug
::
log
(
"af_psql_trgm: similarity result for
$title_escaped
:
$similarity_result
"
,
Debug
::
$
LOG_EXTENDED
);
Debug
::
log
(
"af_psql_trgm: similarity result for
$title_escaped
:
$similarity_result
"
,
Debug
::
LOG_EXTENDED
);
if
(
$similarity_result
>=
$similarity
)
{
if
(
$similarity_result
>=
$similarity
)
{
Debug
::
log
(
"af_psql_trgm: marking article as read (
$similarity_result
>=
$similarity
)"
,
Debug
::
$
LOG_EXTENDED
);
Debug
::
log
(
"af_psql_trgm: marking article as read (
$similarity_result
>=
$similarity
)"
,
Debug
::
LOG_EXTENDED
);
$article
[
"force_catchup"
]
=
true
;
$article
[
"force_catchup"
]
=
true
;
}
}
...
@@ -342,7 +342,12 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -342,7 +342,12 @@ class Af_Psql_Trgm extends Plugin {
return
2
;
return
2
;
}
}
private
function
filter_unknown_feeds
(
$enabled_feeds
)
{
/**
* @param array<int> $enabled_feeds
* @return array<int>
* @throws PDOException
*/
private
function
filter_unknown_feeds
(
$enabled_feeds
)
:
array
{
$tmp
=
array
();
$tmp
=
array
();
foreach
(
$enabled_feeds
as
$feed
)
{
foreach
(
$enabled_feeds
as
$feed
)
{
...
@@ -357,14 +362,4 @@ class Af_Psql_Trgm extends Plugin {
...
@@ -357,14 +362,4 @@ class Af_Psql_Trgm extends Plugin {
return
$tmp
;
return
$tmp
;
}
}
private
function
get_stored_array
(
$name
)
{
$tmp
=
$this
->
host
->
get
(
$this
,
$name
);
if
(
!
is_array
(
$tmp
))
$tmp
=
[];
return
$tmp
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment