<commit_before>module.exports = class GraphDecorator

  @decorateToCacheObject:(data, callback)->
    cacheObject = []
    for datum in data
      if datum.name == "JStatusUpdate"
        localObject = {}
        localObject.modifiedAt = datum.meta.modifiedAt
        localObject["type"]       = "CStatusActivity"
        localObject["_id"]        = datum.id
        localObject["createdAt"]  = datum.meta.createdAt
        localObject["originId"]   = datum.originId
        localObject["originType"] = datum.originType

        console.log datum
        snapshot = {}
        snapshot.bongo_           = { constructorName : "JStatusUpdate" }
        snapshot.slug             = datum.slug
        snapshot.slug_            = datum.slug_
        snapshot.originId         = datum.originId
        snapshot.originType       = datum.originType
        snapshot.meta             = datum.meta
        snapshot.body             = datum.body
        snapshot.attachments      = datum.attachments
        snapshot._id              = datum._id
        snapshot.repliesCount     = datum.relationData.reply?.length? or 0
        snapshot.replies          = datum.relationData.reply? or null
        snapshot.tags             = datum.relationData.tag? or null
        snapshot.counts           = {}
        snapshot.counts.following = 0
        snapshot.counts.followers = datum.relationData.follower?.length or 0

        localObject["snapshot"] = JSON.stringify( snapshot )

        cacheObject.push localObject
    callback cacheObject<commit_msg>[neo4][cache] return formatted json for single activities<commit_after>module.exports = class GraphDecorator

  singleActivites =
    'JStatusUpdate' : true
    'JCodeSnip'     : true
    'JDiscussion'   : true
    'JTutorial'     : true

  bucketActivities =
    'CFollowerBucketActivity'  : true
    'CNewMemberBucketActivity' : true
    'CInstallerBucketActivity' : true

  @decorateToCacheObject:(data, callback)->

    cacheObjects = []

    for datum in data
      localObject = if singleActivites[datum.name]
        @extractSingleActivity(datum)
      else if bucketActivities[datum.name]
        @extractBucketActivity(datum)
      else
        console.log "graphdecorator: unimplemented parsing of #{datum.name}"

      cacheObjects.push localObject

    callback cacheObjects

  @extractSingleActivity:(datum)->

    localObject =
      _id        : datum.id
      type       : datum.name
      originId   : datum.originId
      originType : datum.originType
      createdAt  : datum.meta.createdAt
      modifiedAt : datum.meta.modifiedAt

    snapshot =
      _id               : datum._id
      bongo_            :
        constructorName : datum.name
      slug              : datum.slug
      slug_             : datum.slug_
      originId          : datum.originId
      originType        : datum.originType
      meta              : datum.meta
      body              : datum.body
      attachments       : datum.attachments
      repliesCount      : datum.relationData.reply?.length? or 0
      replies           : datum.relationData.reply? or null
      tags              : datum.relationData.tag? or null
      counts            :
        following       : 0
        followers       : datum.relationData.follower?.length or 0

    localObject["snapshot"] = JSON.stringify snapshot

    return localObject

  @extractBucketActivity:(datum)->

    console.log "TODO: parse #{datum.name}"

{'fraction_non_alphanumeric': 0.0812536273940801, 'fraction_numerical': 0.0020313406848520023, 'mean_word_length': 1.9537275064267352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '7575331', 'n_tokens_mistral': 967, 'n_tokens_neox': 960, 'n_words': 187}