Skip to content

Commit

Permalink
Merge branch 'master' into feedinfotable
Browse files Browse the repository at this point in the history
Signed-off-by: Wolfgang <[email protected]>
  • Loading branch information
wofferl authored Jan 2, 2025
2 parents 6903bc2 + 62a5a10 commit b92c078
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the
## [25.x.x]
### Changed
- add an information list for feeds that displays data such as last or next update dates
- Set maximum delay for updates to "in one day" (#3015)

### Fixed
- OPML import use text field for title if title field is missing (#3016)
Expand Down
2 changes: 2 additions & 0 deletions l10n/ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ OC.L10N.register(
"How many redirects the feed fetcher should follow." : "Cé mhéad athsheolaidh ba chóir don lorgaire beathaithe a leanúint.",
"Maximum number of seconds to wait for an RSS or Atom feed to load; if it takes longer the update will be aborted." : "Uaslíon soicind chun fanacht le fotha RSS nó Atom a luchtú; má thógann sé níos faide cuirfear deireadh leis an nuashonrú.",
"Interval in seconds in which the feeds will be updated." : "Eatramh i soicindí ina ndéanfar na fothaí a nuashonrú.",
"Use next update time for feed updates" : "Úsáid an chéad am nuashonraithe eile le haghaidh nuashonruithe fotha",
"Enable this to use the calculated next update time for feed updates. Disable to update feeds based solely on the update interval." : "Cumasaigh é seo chun an chéad am nuashonraithe eile ríofa a úsáid le haghaidh nuashonruithe fothaí. Díchumasaigh fothaí a nuashonrú bunaithe ar an eatramh nuashonraithe amháin.",
"Article list" : "Liosta alt",
"Article details" : "Sonraí alt",
"No article selected" : "Níor roghnaíodh aon alt",
Expand Down
2 changes: 2 additions & 0 deletions l10n/ga.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"How many redirects the feed fetcher should follow." : "Cé mhéad athsheolaidh ba chóir don lorgaire beathaithe a leanúint.",
"Maximum number of seconds to wait for an RSS or Atom feed to load; if it takes longer the update will be aborted." : "Uaslíon soicind chun fanacht le fotha RSS nó Atom a luchtú; má thógann sé níos faide cuirfear deireadh leis an nuashonrú.",
"Interval in seconds in which the feeds will be updated." : "Eatramh i soicindí ina ndéanfar na fothaí a nuashonrú.",
"Use next update time for feed updates" : "Úsáid an chéad am nuashonraithe eile le haghaidh nuashonruithe fotha",
"Enable this to use the calculated next update time for feed updates. Disable to update feeds based solely on the update interval." : "Cumasaigh é seo chun an chéad am nuashonraithe eile ríofa a úsáid le haghaidh nuashonruithe fothaí. Díchumasaigh fothaí a nuashonrú bunaithe ar an eatramh nuashonraithe amháin.",
"Article list" : "Liosta alt",
"Article details" : "Sonraí alt",
"No article selected" : "Níor roghnaíodh aon alt",
Expand Down
6 changes: 6 additions & 0 deletions lib/Config/FetcherConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class FetcherConfig
'application/atom+xml;q=0.6, application/xml;q=0.4, ' .
'text/xml;q=0.4, */*;q=0.2';

/**
* Duration after which the feed is considered sleepy.
* @var int
*/
public const SLEEPY_DURATION = 86400;

/**
* FetcherConfig constructor.
*
Expand Down
5 changes: 4 additions & 1 deletion lib/Fetcher/FeedFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ public function fetch(
$location
);

$feed->setNextUpdateTime($resource->getNextUpdate()?->getTimestamp());
$feed->setNextUpdateTime(nextUpdateTime: $resource->getNextUpdate(
sleepyDuration: $this->fetcherConfig::SLEEPY_DURATION
)?->getTimestamp());

$this->logger->debug(
'Feed {url} was parsed and nextUpdateTime is {nextUpdateTime}',
[
Expand Down
38 changes: 5 additions & 33 deletions tests/updater/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ teardown() {
# Get the current time
current_time=$(date +%s)

# Calculate the expected time range (+1 hour with some tolerance)
expected_time_min=$((current_time + 3600 - 60)) # 1 hour - 1 minute tolerance
expected_time_max=$((current_time + 3600 + 60)) # 1 hour + 1 minute tolerance
# Calculate the expected time range (+1 day with some tolerance)
expected_time_min=$((current_time + 86400 - 60)) # 1 hour - 1 minute tolerance
expected_time_max=$((current_time + 86400 + 60)) # 1 hour + 1 minute tolerance

php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 15 -s 9 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml
# Trigger Update
Expand All @@ -88,8 +88,8 @@ teardown() {

UpdateTime2=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds | jq '.feeds | .[0].nextUpdateTime')

# Assert that UpdateTime2 is within the expected range
run bash -c "[[ $UpdateTime2 -ge $expected_time_min && $UpdateTime2 -le $expected_time_max ]]"
# Assert that UpdateTime2 is within the expected range and print the timestamp if not
run bash -c "[[ \$UpdateTime2 -ge \$expected_time_min && \$UpdateTime2 -le \$expected_time_max ]] || echo \"UpdateTime2 is out of range: \$UpdateTime2\""
assert_success

}
Expand Down Expand Up @@ -123,34 +123,6 @@ teardown() {
assert_output --partial "${ID_LIST1[*]}"
}

# older date is not a thing anymore
#@test "[$TESTSUITE] Test feed with 'outdated' items https://github.com/nextcloud/news/issues/2236 " {
# # Create Feed, for the first fetch a timestamp today -1 year is used.
# FEEDID=$(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} POST ${BASE_URLv1}/feeds url=$TEST_FEED | grep -Po '"id":\K([0-9]+)')
#
# sleep 2
#
# # Get Items
# ID_LIST1=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
#
# # Generate Feed with older items (-o yes)
# php ${BATS_TEST_DIRNAME}/../test_helper/php-feed-generator/feed-generator.php -a 15 -s 9 -f ${BATS_TEST_DIRNAME}/../test_helper/feeds/test.xml -o yes
#
# # Trigger Update
# http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/feeds/update userId=${user} feedId=$FEEDID
#
# sleep 2
#
# # Get Items again
# ID_LIST2=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))
#
# output="${ID_LIST2[*]}"
#
# # Check that they are not equal but that they match partially.
# assert_not_equal "${ID_LIST1[*]}" "${ID_LIST2[*]}"
# assert_output --partial "${ID_LIST1[*]}"
#}

@test "[$TESTSUITE] Test purge with small feed" {
# Disable useNextUpdateTime
./occ config:app:set news useNextUpdateTime --value=false
Expand Down

0 comments on commit b92c078

Please sign in to comment.