<commit_before>! Copyright (C) 2017 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs cli.git concurrency.combinators
concurrency.semaphores formatting fry http.client io
io.directories json.reader kernel locals math namespaces
sequences ;
IN: github

SYMBOL: github-username
SYMBOL: github-token

:: get-organization-repositories-with-credentials ( organization username token -- seq )
    0 [ dup ] [
        1 + dup
        [ username token organization ] dip
        "https://%s:%s@api.github.com/orgs/%s/repos?per_page=100&page=%d" sprintf http-get nip json>
        dup empty? [ 2drop f f ] [ ] if
    ] produce nip concat ;

: get-organization-repositories ( organization -- seq )
    github-username get
    github-token get
    get-organization-repositories-with-credentials ;

: sync-organization-with-credentials ( directory organization username token -- )
    get-organization-repositories-with-credentials
    [ "ssh_url" of ] map sync-repositories ;

: sync-organization ( directory organization -- )
    github-username get
    github-token get
    sync-organization-with-credentials ;
<commit_msg>web-services.github: Fix the IN:.<commit_after>! Copyright (C) 2017 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs cli.git concurrency.combinators
concurrency.semaphores formatting fry http.client io
io.directories json.reader kernel locals math namespaces
sequences ;
IN: web-services.github

SYMBOL: github-username
SYMBOL: github-token

:: get-organization-repositories-with-credentials ( organization username token -- seq )
    0 [ dup ] [
        1 + dup
        [ username token organization ] dip
        "https://%s:%s@api.github.com/orgs/%s/repos?per_page=100&page=%d" sprintf http-get nip json>
        dup empty? [ 2drop f f ] [ ] if
    ] produce nip concat ;

: get-organization-repositories ( organization -- seq )
    github-username get
    github-token get
    get-organization-repositories-with-credentials ;

: sync-organization-with-credentials ( directory organization username token -- )
    get-organization-repositories-with-credentials
    [ "ssh_url" of ] map sync-repositories ;

: sync-organization ( directory organization -- )
    github-username get
    github-token get
    sync-organization-with-credentials ;

{'fraction_non_alphanumeric': 0.10564898663216904, 'fraction_numerical': 0.008624407072013798, 'mean_word_length': 3.4874274661508706, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6526245', 'n_tokens_mistral': 725, 'n_tokens_neox': 659, 'n_words': 173}