From 0e3aa9802e2554980e730f02ca2ca969f538d4d2 Mon Sep 17 00:00:00 2001 From: dkhamsing Date: Tue, 7 May 2019 18:39:12 -0700 Subject: [PATCH] =?UTF-8?q?[script]=20Improve=20=F0=9F=98=8A=20[ci=20skip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/osia_convert.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/osia_convert.rb b/.github/osia_convert.rb index 34291d5608cb..f80029ad762c 100644 --- a/.github/osia_convert.rb +++ b/.github/osia_convert.rb @@ -11,6 +11,8 @@ NOT_ENGLISH = '🌐' ARCHIVE_TAG = 'archive' +LATEST_NUM = 15 + # Helpers def app_store_total(j) @@ -57,14 +59,12 @@ def apps_for_cat(apps, id) s.sort_by { |k, v| k['title'].downcase } end -LATEST_NUM = 15 - -def apps_latest(apps) +def apps_latest(apps, num) a = apps.select { |a| a['date_added'] != nil } .sort_by { |k, v| DateTime.parse(k['date_added']) } .reverse - a[0..LATEST_NUM - 1] + a[0..num - 1] end def output_apps(apps, appstoreonly) @@ -206,12 +206,12 @@ def write_archive(j) puts "wrote #{file} ✨" end -def write_latest(j) +def write_latest(j, num) t = j['title'] - desc = "These are the #{LATEST_NUM} latest entries from the [main list](https://github.com/dkhamsing/open-source-ios-apps).\n\n" + desc = "These are the #{num} latest entries from the [main list](https://github.com/dkhamsing/open-source-ios-apps).\n\n" f = "## Contact\n\n- [github.com/dkhamsing](https://github.com/dkhamsing)\n- [twitter.com/dkhamsing](https://twitter.com/dkhamsing)\n" apps = j["projects"] - latest = apps_latest apps + latest = apps_latest(apps, num) output = "\# #{t} Latest\n\n" output << desc @@ -311,4 +311,4 @@ def write_list(j, file, appstoreonly = false) write_list(j, README) write_archive(j) write_list(j, APPSTORE, true) -write_latest(j) +write_latest(j, LATEST_NUM)