Skip to content

Commit

Permalink
[script] Improve 😊 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhamsing committed May 8, 2019
1 parent 7444b31 commit 0e3aa98
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/osia_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
NOT_ENGLISH = '🌐'
ARCHIVE_TAG = 'archive'

LATEST_NUM = 15

# Helpers

def app_store_total(j)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 0e3aa98

Please sign in to comment.