Add script to cache the song hashmap in PHP
authorCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 02:21:03 +0000 (10:21 +0800)
committerCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 02:21:03 +0000 (10:21 +0800)
src/cachehashmap.php [new file with mode: 0644]
src/prankdigest.php

diff --git a/src/cachehashmap.php b/src/cachehashmap.php
new file mode 100644 (file)
index 0000000..2698990
--- /dev/null
@@ -0,0 +1,9 @@
+<?php declare(strict_types=1);
+
+require('common.php');
+
+$songHashMap = foldMap(
+    ☐(∘(field(0), delemit(' ')))(∘(field(5), delemit('/')))
+)(foldMap(∘(lines, 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/songs.*.txt')));
+
+file_put_contents(__DIR__ . '/hashmap.txt', serialize($songHashMap));
index b11e399..f401759 100644 (file)
@@ -18,10 +18,7 @@ $diffEmojiMap = [
     'Edit' => '📓'
 ];
 
-$songHashMap = foldMap(
-    ☐(∘(field(0), delemit(' ')))(∘(field(5), delemit('/')))
-)(foldMap(∘(lines, 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/songs.*.txt')));
-
+$songHashMap = unserialize(file_get_contents(__DIR__ . '/hashmap.txt'));
 $scoreFiles = foldMap(∘(☐(lhead)(null), 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/*.scores.txt'));
 $faveFiles = foldMap(☐(null)(∘(lines, 'trim', 'file_get_contents')))(glob(PATH_TO_GROOVENET . '/*.favourites.txt'));
 $names = map(☐(produceValue(0))(null))(array_keys($faveFiles));